1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Maurinko [17]
3 years ago
14

how to Write a simple Java socket programming that a client sends a text and server receives and print.

Computers and Technology
1 answer:
antiseptic1488 [7]3 years ago
3 0

Answer:

Java Socket programming is used for communication between the applications running on different JRE.

Java Socket programming can be connection-oriented or connection-less.

Socket and ServerSocket classes are used for connection-oriented socket programming and DatagramSocket and DatagramPacket classes are used for connection-less socket programming.

The client in socket programming must know two information:

IP Address of Server, and

Port number.

Here, we are going to make one-way client and server communication. In this application, client sends a message to the server, server reads the message and prints it. Here, two classes are being used: Socket and ServerSocket. The Socket class is used to communicate client and server. Through this class, we can read and write message. The ServerSocket class is used at server-side. The accept() method of ServerSocket class blocks the console until the client is connected. After the successful connection of client, it returns the instance of Socket at server-side.

Explanation:

Creating Client:

import java.io.*;

import java.net.*;

public class MyServer {

public static void main(String[] args){

try{

ServerSocket ss=new ServerSocket(6666);

Socket s=ss.accept();//establishes connection.

DataInputStream dis=new DataInputStream(s.getInputStream());

You might be interested in
You would like to search for information about storms but not tornadoes. What type of search strategy may be useful?
Norma-Jean [14]

Answer:

boolean search

Explanation:

4 0
3 years ago
Read 2 more answers
Its an HTML5 anyone kwons
Aleksandr [31]

Answer:

1 will be stored in result

Explanation:

Given

The lines of code

Required

Determine the value stored in result

The value stored in result is determine by the condition (x<3 && y ==6)

In the first line, the value of x is 2 and the value of y is 6

So: x<3 is true because x = 2 and 2 is less than 3

y == 6 is also true because y = 6 and 6 is equal to 6

So, the condition (x<3 && y ==6) is true and true will be saved in variable result

Because result is a Boolean variable which can only take true or false value

1 represents true

0 represents false

<em>So, 1 will be stored in result</em>

7 0
3 years ago
Jefffffffffffffffffffffffffcfffryyyryrryryyyyyyyyyyyyyyynhghgnc nb hc
kati45 [8]

Answer:

huh?

Explanation:

5 0
3 years ago
Read 2 more answers
What are concepts and accrual​
Darya [45]

Answer:

umm oh nvrm i forgot

Explanation:

4 0
3 years ago
Read 2 more answers
True or False
umka2103 [35]

Answer:

true

Explanation:

qqqqqqqqqqqqqqqqqqqq

3 0
3 years ago
Other questions:
  • 14. Which commercial RDBMS product was the first to hit the market and is the biggest?
    15·1 answer
  • An online service provider provides its users with hosted​ computers, an operating​ system, and a database management system​ (D
    6·1 answer
  • Describe business benefits of using wireless electricity?
    6·1 answer
  • Which data table display compares report metrics to the website average?
    6·1 answer
  • What technical elements can a film director manipulate to achieve the final product, conveying his ideology and vision?
    11·1 answer
  • To share a document in my online electronic journal, I should select the option to _____.
    14·1 answer
  • How can a signature be added to an email message? Check all that apply.
    10·2 answers
  • Which U.S. government agency first funded the development of the Internet?
    12·2 answers
  • Write a program to have the computer guess at a number between 1 and 20. This program has you, the user choose a number between
    9·1 answer
  • Need help ASAP <br><br> Thankss + BRAINLIST only for correct answers
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!