Client/Server ProgrammingHow does the socket API accept() function work?Java client socket returned by ServerSocket.accept()Java TCP Client Server working over LAN with port Forwarding but not with hamachiWhen there is a persistent connection how does a server identify subsequent request?I am confused about tcp demultiplexing?Java - Is it possible to send a client to another server?limit certain number of clients to connect to serverCannot communicate once bufferedwriter is close in java socket programmingJava TCP Hole PunchingServerSockets connecting to client
A PEMDAS issue request for explanation
2 load centers under 1 meter: do you need bonding and main breakers at both?
How would two worlds first establish an exchange rate between their currencies
Problem with listing a directory to grep
Why is the the worst case for this function O(n*n)
The meaning of "offing" in "an agreement in the offing"
Walking on an infinite grid
Contour plot of a sequence of spheres with increasing radius
Is future tense in English really a myth?
Strategies for dealing with chess burnout?
How should Thaumaturgy's "three times as loud as normal" be interpreted?
Distinguishing between octahedral and tetrahedral holes
Is there a "right" way to interpret a novel, if not, how do we make sure our novel is interpreted correctly?
Why would an AC motor heavily shake when driven with certain frequencies?
Why do the British opposition parties not want a new election?
How can I finish my PhD?
LGPL HDL in larger FPGA design
How invisible hand adjusts stock prices if company is listed on multiple exchanges, under multiple currencies, and one of the currencies plunges?
RANK used in 'where' returns invalid column, but exists in results set
Was Robin Hood's point of view ethically sound?
Short story: Interstellar inspector senses "off" nature of planet hiding aggressive culture
Stack class in Java8
Why can linguists decide which use of language is correct and which is not?
How should we understand "unobscured by flying friends" in this context?
Client/Server Programming
How does the socket API accept() function work?Java client socket returned by ServerSocket.accept()Java TCP Client Server working over LAN with port Forwarding but not with hamachiWhen there is a persistent connection how does a server identify subsequent request?I am confused about tcp demultiplexing?Java - Is it possible to send a client to another server?limit certain number of clients to connect to serverCannot communicate once bufferedwriter is close in java socket programmingJava TCP Hole PunchingServerSockets connecting to client
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am practicing a simple java program where I am demonstrating simple client server interaction. The fist part of message from server gets transferred. Then program just continues to run and does not execute? Do we need to create a new socket for each individual traffic?
Server code
server = new ServerSocket(4587);
System.out.print("Starting the Server on port " + server.getLocalPort() + "n");
System.out.println("Waiting for client...");
Socket client = server.accept();
BufferedWriter br = new BufferedWriter(new OutputStreamWriter(client.getOutputStream()));
BufferedReader br1 = new BufferedReader(new InputStreamReader(client.getInputStream()));
br.write("Hello, you are connected to Server. What is your name?");
br.write("n");
br.flush();
while((s=br1.readLine())!=null)
br.write("Thank you ");
br.newLine();
br.flush();
}
Client code
String stdin;
System.out.println("Attempting to connect to " + hostname + ":" + port);
client = new Socket("localhost", 4587);
System.out.println("Connection Established");
BufferedReader br = new BufferedReader(new InputStreamReader(client.getInputStream()));
while ((stdin = br.readLine()) != null)
System.out.println(stdin);
BufferedWriter br1 = new BufferedWriter(new OutputStreamWriter(client.getOutputStream()));
br1.write("Mike");
br1.write("n");
br1.flush();
while ((stdin = br.readLine()) != null)
System.out.println(stdin);
Server Output
Starting the Server on port4587
Waiting for client....
Client Output
Attempting to connect to :123
Connection Established
Hello you are connected to Server, What is ur name
If this could help..after this both loop
java sockets tcp
add a comment |
I am practicing a simple java program where I am demonstrating simple client server interaction. The fist part of message from server gets transferred. Then program just continues to run and does not execute? Do we need to create a new socket for each individual traffic?
Server code
server = new ServerSocket(4587);
System.out.print("Starting the Server on port " + server.getLocalPort() + "n");
System.out.println("Waiting for client...");
Socket client = server.accept();
BufferedWriter br = new BufferedWriter(new OutputStreamWriter(client.getOutputStream()));
BufferedReader br1 = new BufferedReader(new InputStreamReader(client.getInputStream()));
br.write("Hello, you are connected to Server. What is your name?");
br.write("n");
br.flush();
while((s=br1.readLine())!=null)
br.write("Thank you ");
br.newLine();
br.flush();
}
Client code
String stdin;
System.out.println("Attempting to connect to " + hostname + ":" + port);
client = new Socket("localhost", 4587);
System.out.println("Connection Established");
BufferedReader br = new BufferedReader(new InputStreamReader(client.getInputStream()));
while ((stdin = br.readLine()) != null)
System.out.println(stdin);
BufferedWriter br1 = new BufferedWriter(new OutputStreamWriter(client.getOutputStream()));
br1.write("Mike");
br1.write("n");
br1.flush();
while ((stdin = br.readLine()) != null)
System.out.println(stdin);
Server Output
Starting the Server on port4587
Waiting for client....
Client Output
Attempting to connect to :123
Connection Established
Hello you are connected to Server, What is ur name
If this could help..after this both loop
java sockets tcp
Why the down vote? He has shown effort.
– bblincoe
Jan 23 '14 at 13:26
Well, IMHO, the the problem is reported in a vague way, and there is no clear reference to the code.
– Alexis Leclerc
Jan 23 '14 at 13:33
add a comment |
I am practicing a simple java program where I am demonstrating simple client server interaction. The fist part of message from server gets transferred. Then program just continues to run and does not execute? Do we need to create a new socket for each individual traffic?
Server code
server = new ServerSocket(4587);
System.out.print("Starting the Server on port " + server.getLocalPort() + "n");
System.out.println("Waiting for client...");
Socket client = server.accept();
BufferedWriter br = new BufferedWriter(new OutputStreamWriter(client.getOutputStream()));
BufferedReader br1 = new BufferedReader(new InputStreamReader(client.getInputStream()));
br.write("Hello, you are connected to Server. What is your name?");
br.write("n");
br.flush();
while((s=br1.readLine())!=null)
br.write("Thank you ");
br.newLine();
br.flush();
}
Client code
String stdin;
System.out.println("Attempting to connect to " + hostname + ":" + port);
client = new Socket("localhost", 4587);
System.out.println("Connection Established");
BufferedReader br = new BufferedReader(new InputStreamReader(client.getInputStream()));
while ((stdin = br.readLine()) != null)
System.out.println(stdin);
BufferedWriter br1 = new BufferedWriter(new OutputStreamWriter(client.getOutputStream()));
br1.write("Mike");
br1.write("n");
br1.flush();
while ((stdin = br.readLine()) != null)
System.out.println(stdin);
Server Output
Starting the Server on port4587
Waiting for client....
Client Output
Attempting to connect to :123
Connection Established
Hello you are connected to Server, What is ur name
If this could help..after this both loop
java sockets tcp
I am practicing a simple java program where I am demonstrating simple client server interaction. The fist part of message from server gets transferred. Then program just continues to run and does not execute? Do we need to create a new socket for each individual traffic?
Server code
server = new ServerSocket(4587);
System.out.print("Starting the Server on port " + server.getLocalPort() + "n");
System.out.println("Waiting for client...");
Socket client = server.accept();
BufferedWriter br = new BufferedWriter(new OutputStreamWriter(client.getOutputStream()));
BufferedReader br1 = new BufferedReader(new InputStreamReader(client.getInputStream()));
br.write("Hello, you are connected to Server. What is your name?");
br.write("n");
br.flush();
while((s=br1.readLine())!=null)
br.write("Thank you ");
br.newLine();
br.flush();
}
Client code
String stdin;
System.out.println("Attempting to connect to " + hostname + ":" + port);
client = new Socket("localhost", 4587);
System.out.println("Connection Established");
BufferedReader br = new BufferedReader(new InputStreamReader(client.getInputStream()));
while ((stdin = br.readLine()) != null)
System.out.println(stdin);
BufferedWriter br1 = new BufferedWriter(new OutputStreamWriter(client.getOutputStream()));
br1.write("Mike");
br1.write("n");
br1.flush();
while ((stdin = br.readLine()) != null)
System.out.println(stdin);
Server Output
Starting the Server on port4587
Waiting for client....
Client Output
Attempting to connect to :123
Connection Established
Hello you are connected to Server, What is ur name
If this could help..after this both loop
java sockets tcp
java sockets tcp
edited Jan 24 '14 at 12:35
Koneri
asked Jan 23 '14 at 13:14
KoneriKoneri
1821 gold badge9 silver badges25 bronze badges
1821 gold badge9 silver badges25 bronze badges
Why the down vote? He has shown effort.
– bblincoe
Jan 23 '14 at 13:26
Well, IMHO, the the problem is reported in a vague way, and there is no clear reference to the code.
– Alexis Leclerc
Jan 23 '14 at 13:33
add a comment |
Why the down vote? He has shown effort.
– bblincoe
Jan 23 '14 at 13:26
Well, IMHO, the the problem is reported in a vague way, and there is no clear reference to the code.
– Alexis Leclerc
Jan 23 '14 at 13:33
Why the down vote? He has shown effort.
– bblincoe
Jan 23 '14 at 13:26
Why the down vote? He has shown effort.
– bblincoe
Jan 23 '14 at 13:26
Well, IMHO, the the problem is reported in a vague way, and there is no clear reference to the code.
– Alexis Leclerc
Jan 23 '14 at 13:33
Well, IMHO, the the problem is reported in a vague way, and there is no clear reference to the code.
– Alexis Leclerc
Jan 23 '14 at 13:33
add a comment |
3 Answers
3
active
oldest
votes
Your server will first create a connection with the client through the accept
method. If you wish to have multiple clients you will need to change your code accordingly to accept that.
On the client side, you're using n
to delineate the end of a message. This will work fine. Every time you send a new message use n
to indicate the end of the message.
On the server side, you should continue reading from I/O until you see the n
. At that point you have received the entire message. Process it and than start listening again.
Edit:
Since you are waiting for the name of the client, you could simply do the following on the server:
BufferedWriter bout = new BufferedWriter(new OutputStreamWriter(client.getOutputStream()));
BufferedReader bin = new BufferedReader(new InputStreamWriter(client.getInputStream()));
// Wait for incoming name from client.
String name = bin.readline();
System.out.println(name);
// Send a reply.
bout.write("Thank youn");
bout.flush();
Similarly, on the client (assuming bin
and bout
are defined the same as above):
// Send name to server.
bout.write("Namen");
bout.flush();
// Get a response from the server and print to console.
String response = bin.readline();
System.out.println(response);
like should i use while loop while reading from client
– Koneri
Jan 24 '14 at 12:12
That would be acceptable - it really just depends on what you're trying to achieve. Inside yourwhile
loop you can read each message and process it. After your done you'll go back to reading the next line. You may want to consider listening forever (in awhile(true)
loop) on a separate thread to allow the server to do other things besides listening all the time.
– bblincoe
Jan 24 '14 at 12:31
I edited my server code. Could you please take a look at it
– Koneri
Jan 24 '14 at 12:34
@Koneri I've updated my answer. Hopefully it will get you started.
– bblincoe
Jan 24 '14 at 13:35
Fine this solves it thank you. And i had one question one connection is set up between client and server. Can we call the method of server and receive the response.
– Koneri
Jan 25 '14 at 8:06
|
show 1 more comment
This is because BufferedReader has a default buffer = 8K when in reading process and this process is block I/O, so this will hang in that point. You should read the full message from client by server side.
add a comment |
Your problem is with the loop on the client side. It will be stuck in the loop as it waits to readlines sent from the server infinitely. (ie, after reading the first line from the server, it will expect more lines from the server and wait to read them).
To exit the loop you need to send an EOF signal or end of stream signal (according to the docs: http://docs.oracle.com/javase/7/docs/api/java/io/BufferedReader.html#readLine%28%29)
He's sending an
which is his indicator for EOF.
– bblincoe
Jan 24 '14 at 12:31
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f21309266%2fclient-server-programming%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Your server will first create a connection with the client through the accept
method. If you wish to have multiple clients you will need to change your code accordingly to accept that.
On the client side, you're using n
to delineate the end of a message. This will work fine. Every time you send a new message use n
to indicate the end of the message.
On the server side, you should continue reading from I/O until you see the n
. At that point you have received the entire message. Process it and than start listening again.
Edit:
Since you are waiting for the name of the client, you could simply do the following on the server:
BufferedWriter bout = new BufferedWriter(new OutputStreamWriter(client.getOutputStream()));
BufferedReader bin = new BufferedReader(new InputStreamWriter(client.getInputStream()));
// Wait for incoming name from client.
String name = bin.readline();
System.out.println(name);
// Send a reply.
bout.write("Thank youn");
bout.flush();
Similarly, on the client (assuming bin
and bout
are defined the same as above):
// Send name to server.
bout.write("Namen");
bout.flush();
// Get a response from the server and print to console.
String response = bin.readline();
System.out.println(response);
like should i use while loop while reading from client
– Koneri
Jan 24 '14 at 12:12
That would be acceptable - it really just depends on what you're trying to achieve. Inside yourwhile
loop you can read each message and process it. After your done you'll go back to reading the next line. You may want to consider listening forever (in awhile(true)
loop) on a separate thread to allow the server to do other things besides listening all the time.
– bblincoe
Jan 24 '14 at 12:31
I edited my server code. Could you please take a look at it
– Koneri
Jan 24 '14 at 12:34
@Koneri I've updated my answer. Hopefully it will get you started.
– bblincoe
Jan 24 '14 at 13:35
Fine this solves it thank you. And i had one question one connection is set up between client and server. Can we call the method of server and receive the response.
– Koneri
Jan 25 '14 at 8:06
|
show 1 more comment
Your server will first create a connection with the client through the accept
method. If you wish to have multiple clients you will need to change your code accordingly to accept that.
On the client side, you're using n
to delineate the end of a message. This will work fine. Every time you send a new message use n
to indicate the end of the message.
On the server side, you should continue reading from I/O until you see the n
. At that point you have received the entire message. Process it and than start listening again.
Edit:
Since you are waiting for the name of the client, you could simply do the following on the server:
BufferedWriter bout = new BufferedWriter(new OutputStreamWriter(client.getOutputStream()));
BufferedReader bin = new BufferedReader(new InputStreamWriter(client.getInputStream()));
// Wait for incoming name from client.
String name = bin.readline();
System.out.println(name);
// Send a reply.
bout.write("Thank youn");
bout.flush();
Similarly, on the client (assuming bin
and bout
are defined the same as above):
// Send name to server.
bout.write("Namen");
bout.flush();
// Get a response from the server and print to console.
String response = bin.readline();
System.out.println(response);
like should i use while loop while reading from client
– Koneri
Jan 24 '14 at 12:12
That would be acceptable - it really just depends on what you're trying to achieve. Inside yourwhile
loop you can read each message and process it. After your done you'll go back to reading the next line. You may want to consider listening forever (in awhile(true)
loop) on a separate thread to allow the server to do other things besides listening all the time.
– bblincoe
Jan 24 '14 at 12:31
I edited my server code. Could you please take a look at it
– Koneri
Jan 24 '14 at 12:34
@Koneri I've updated my answer. Hopefully it will get you started.
– bblincoe
Jan 24 '14 at 13:35
Fine this solves it thank you. And i had one question one connection is set up between client and server. Can we call the method of server and receive the response.
– Koneri
Jan 25 '14 at 8:06
|
show 1 more comment
Your server will first create a connection with the client through the accept
method. If you wish to have multiple clients you will need to change your code accordingly to accept that.
On the client side, you're using n
to delineate the end of a message. This will work fine. Every time you send a new message use n
to indicate the end of the message.
On the server side, you should continue reading from I/O until you see the n
. At that point you have received the entire message. Process it and than start listening again.
Edit:
Since you are waiting for the name of the client, you could simply do the following on the server:
BufferedWriter bout = new BufferedWriter(new OutputStreamWriter(client.getOutputStream()));
BufferedReader bin = new BufferedReader(new InputStreamWriter(client.getInputStream()));
// Wait for incoming name from client.
String name = bin.readline();
System.out.println(name);
// Send a reply.
bout.write("Thank youn");
bout.flush();
Similarly, on the client (assuming bin
and bout
are defined the same as above):
// Send name to server.
bout.write("Namen");
bout.flush();
// Get a response from the server and print to console.
String response = bin.readline();
System.out.println(response);
Your server will first create a connection with the client through the accept
method. If you wish to have multiple clients you will need to change your code accordingly to accept that.
On the client side, you're using n
to delineate the end of a message. This will work fine. Every time you send a new message use n
to indicate the end of the message.
On the server side, you should continue reading from I/O until you see the n
. At that point you have received the entire message. Process it and than start listening again.
Edit:
Since you are waiting for the name of the client, you could simply do the following on the server:
BufferedWriter bout = new BufferedWriter(new OutputStreamWriter(client.getOutputStream()));
BufferedReader bin = new BufferedReader(new InputStreamWriter(client.getInputStream()));
// Wait for incoming name from client.
String name = bin.readline();
System.out.println(name);
// Send a reply.
bout.write("Thank youn");
bout.flush();
Similarly, on the client (assuming bin
and bout
are defined the same as above):
// Send name to server.
bout.write("Namen");
bout.flush();
// Get a response from the server and print to console.
String response = bin.readline();
System.out.println(response);
edited Jan 24 '14 at 13:34
answered Jan 23 '14 at 13:25
bblincoebblincoe
1,80316 silver badges29 bronze badges
1,80316 silver badges29 bronze badges
like should i use while loop while reading from client
– Koneri
Jan 24 '14 at 12:12
That would be acceptable - it really just depends on what you're trying to achieve. Inside yourwhile
loop you can read each message and process it. After your done you'll go back to reading the next line. You may want to consider listening forever (in awhile(true)
loop) on a separate thread to allow the server to do other things besides listening all the time.
– bblincoe
Jan 24 '14 at 12:31
I edited my server code. Could you please take a look at it
– Koneri
Jan 24 '14 at 12:34
@Koneri I've updated my answer. Hopefully it will get you started.
– bblincoe
Jan 24 '14 at 13:35
Fine this solves it thank you. And i had one question one connection is set up between client and server. Can we call the method of server and receive the response.
– Koneri
Jan 25 '14 at 8:06
|
show 1 more comment
like should i use while loop while reading from client
– Koneri
Jan 24 '14 at 12:12
That would be acceptable - it really just depends on what you're trying to achieve. Inside yourwhile
loop you can read each message and process it. After your done you'll go back to reading the next line. You may want to consider listening forever (in awhile(true)
loop) on a separate thread to allow the server to do other things besides listening all the time.
– bblincoe
Jan 24 '14 at 12:31
I edited my server code. Could you please take a look at it
– Koneri
Jan 24 '14 at 12:34
@Koneri I've updated my answer. Hopefully it will get you started.
– bblincoe
Jan 24 '14 at 13:35
Fine this solves it thank you. And i had one question one connection is set up between client and server. Can we call the method of server and receive the response.
– Koneri
Jan 25 '14 at 8:06
like should i use while loop while reading from client
– Koneri
Jan 24 '14 at 12:12
like should i use while loop while reading from client
– Koneri
Jan 24 '14 at 12:12
That would be acceptable - it really just depends on what you're trying to achieve. Inside your
while
loop you can read each message and process it. After your done you'll go back to reading the next line. You may want to consider listening forever (in a while(true)
loop) on a separate thread to allow the server to do other things besides listening all the time.– bblincoe
Jan 24 '14 at 12:31
That would be acceptable - it really just depends on what you're trying to achieve. Inside your
while
loop you can read each message and process it. After your done you'll go back to reading the next line. You may want to consider listening forever (in a while(true)
loop) on a separate thread to allow the server to do other things besides listening all the time.– bblincoe
Jan 24 '14 at 12:31
I edited my server code. Could you please take a look at it
– Koneri
Jan 24 '14 at 12:34
I edited my server code. Could you please take a look at it
– Koneri
Jan 24 '14 at 12:34
@Koneri I've updated my answer. Hopefully it will get you started.
– bblincoe
Jan 24 '14 at 13:35
@Koneri I've updated my answer. Hopefully it will get you started.
– bblincoe
Jan 24 '14 at 13:35
Fine this solves it thank you. And i had one question one connection is set up between client and server. Can we call the method of server and receive the response.
– Koneri
Jan 25 '14 at 8:06
Fine this solves it thank you. And i had one question one connection is set up between client and server. Can we call the method of server and receive the response.
– Koneri
Jan 25 '14 at 8:06
|
show 1 more comment
This is because BufferedReader has a default buffer = 8K when in reading process and this process is block I/O, so this will hang in that point. You should read the full message from client by server side.
add a comment |
This is because BufferedReader has a default buffer = 8K when in reading process and this process is block I/O, so this will hang in that point. You should read the full message from client by server side.
add a comment |
This is because BufferedReader has a default buffer = 8K when in reading process and this process is block I/O, so this will hang in that point. You should read the full message from client by server side.
This is because BufferedReader has a default buffer = 8K when in reading process and this process is block I/O, so this will hang in that point. You should read the full message from client by server side.
answered Jan 23 '14 at 13:26
richierichie
1793 bronze badges
1793 bronze badges
add a comment |
add a comment |
Your problem is with the loop on the client side. It will be stuck in the loop as it waits to readlines sent from the server infinitely. (ie, after reading the first line from the server, it will expect more lines from the server and wait to read them).
To exit the loop you need to send an EOF signal or end of stream signal (according to the docs: http://docs.oracle.com/javase/7/docs/api/java/io/BufferedReader.html#readLine%28%29)
He's sending an
which is his indicator for EOF.
– bblincoe
Jan 24 '14 at 12:31
add a comment |
Your problem is with the loop on the client side. It will be stuck in the loop as it waits to readlines sent from the server infinitely. (ie, after reading the first line from the server, it will expect more lines from the server and wait to read them).
To exit the loop you need to send an EOF signal or end of stream signal (according to the docs: http://docs.oracle.com/javase/7/docs/api/java/io/BufferedReader.html#readLine%28%29)
He's sending an
which is his indicator for EOF.
– bblincoe
Jan 24 '14 at 12:31
add a comment |
Your problem is with the loop on the client side. It will be stuck in the loop as it waits to readlines sent from the server infinitely. (ie, after reading the first line from the server, it will expect more lines from the server and wait to read them).
To exit the loop you need to send an EOF signal or end of stream signal (according to the docs: http://docs.oracle.com/javase/7/docs/api/java/io/BufferedReader.html#readLine%28%29)
Your problem is with the loop on the client side. It will be stuck in the loop as it waits to readlines sent from the server infinitely. (ie, after reading the first line from the server, it will expect more lines from the server and wait to read them).
To exit the loop you need to send an EOF signal or end of stream signal (according to the docs: http://docs.oracle.com/javase/7/docs/api/java/io/BufferedReader.html#readLine%28%29)
answered Jan 23 '14 at 13:40
diddlesdiddles
1046 bronze badges
1046 bronze badges
He's sending an
which is his indicator for EOF.
– bblincoe
Jan 24 '14 at 12:31
add a comment |
He's sending an
which is his indicator for EOF.
– bblincoe
Jan 24 '14 at 12:31
He's sending a
n
which is his indicator for EOF.– bblincoe
Jan 24 '14 at 12:31
He's sending a
n
which is his indicator for EOF.– bblincoe
Jan 24 '14 at 12:31
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f21309266%2fclient-server-programming%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Why the down vote? He has shown effort.
– bblincoe
Jan 23 '14 at 13:26
Well, IMHO, the the problem is reported in a vague way, and there is no clear reference to the code.
– Alexis Leclerc
Jan 23 '14 at 13:33