Java socket automated communication - java

I have a problem with the communication between a server and a client. I am trying to figure out a way of the communicating automatically because they have to exchange some parameters. However, with the code I wrote the server either keeps on sending the same message to the client after the client confirms the message or the client receives nothing at all. The sockets and everything have been setup up before. The function sendString() and receiveString() are identical inboth code examples. Is there a proper way of doing this? I dont get why this doesnt work...
Server:
String buffer;
while(true){
buffer = client.receiveString();
if(buffer != null && buffer.equals("ready")){
System.out.println("Client is ready");
client.sendString("ready");
while(true){
buffer = client.receiveString();
if(buffer != null && buffer.equals("k")){
System.out.println("stopped");
break;
}
}
break;
}
}
public String receiveString() throws IOException{ //From the client class
if(dataIn.available() > 0){
int length = dataIn.readInt();
byte[] b = new byte[length];
dataIn.readFully(b, 0, b.length);
return new String(b, Charset.forName("UTF-8"));
}
return null;
}
public void sendString(String msg) throws IOException{
byte[] b = msg.getBytes(Charset.forName("UTF-8"));
dataOut.writeInt(b.length);
dataOut.write(b);
}
Client:
String buffer;
while(true){
sendString("ready");
buffer = receiveString();
if(buffer!=null)
System.out.println(buffer);
if(buffer != null && buffer.equals("ready")){
System.out.println("Server is ready");
sendString("k");
break;
}
}

This code might work in your case:
Client.java
public class Client {
public static void main(String[] args) throws Exception {
try (Socket socket = new Socket("localhost", 8080)) {
try (BufferedOutputStream out = new BufferedOutputStream(socket.getOutputStream());
Scanner in = new Scanner(socket.getInputStream())) {
System.out.println("Client: sending ready.");
writeLine("ready", out);
System.out.println("Client: sent ready.");
String line = in.nextLine();
if ("ready".equals(line)) {
System.out.println("Client: server is ready");
writeLine("k", out);
}
}
}
}
private static void writeLine(final String line, final BufferedOutputStream out) throws IOException {
out.write((line +"\n").getBytes());
out.flush();
}
}
Server.java:
public class Server {
public static void main(String[] args) throws Exception {
boolean running = true;
try (ServerSocket socket = new ServerSocket(8080, 0)) {
while (running) {
System.out.println("Waiting for client accept.");
try (final Socket client = socket.accept();
final Scanner in = new Scanner(client.getInputStream());
final BufferedOutputStream out = new BufferedOutputStream(client.getOutputStream())) {
System.out.println("Waiting for client ready.");
String line = readLine(in);
if ("ready".equals(line)) {
writeLine("ready", out);
while (running) {
line = readLine(in);
if (line != null && line.equals("k")) {
System.out.println("Server: received stop signal");
running = false;
} else {
Thread.sleep(100);
System.out.println("Server: waiting for command.");
}
}
}
}
}
}
}
private static String readLine(final Scanner in) {
String line = in.nextLine();
System.out.println("Server: client sent " + line);
return line;
}
private static void writeLine(final String line, final BufferedOutputStream out) throws IOException {
out.write((line + "\n").getBytes());
out.flush();
}
}
So what is happening here?
Server socket waits for a client. If client connects, it waits for it to send something (in a blocking manner!). If its "ready", it checks for other commands.
Note: This only works for a single server<->client connection at a time. Dunno if this suites your application. The Server gets shutdown if client sends "k", like in your case.

Related

Why is my message sent only once in Java socket server?

there is a server that is considered to server multiple clients at the same time.
So when clients connects, he is added to clients array. And when server gets the message, it is sent to all the clients.
It works perfectly when one client is connected, but when I have 2 clients at the same time, the message is sent only once, it doesn't work anymore after that. What's the problem?
Server
static DataInputStream inputStream;
static DataOutputStream outputStream;
static ServerSocket serverSocket;
static final int PORT = 3003;
static Socket someClient;
static List<Socket> clients = new ArrayList<>();
public Server()
{
start();
}
public static void main(String[] args) throws IOException
{
try{
serverSocket = new ServerSocket(PORT);
print("Server started on " + serverSocket.getInetAddress().getHostAddress());
while (true)
{
someClient = serverSocket.accept();
new Server();
}
} catch (Exception e){
e.printStackTrace();
}
}
#Override
public void run()
{
try{
clients.add(someClient);
print("Connected from " + someClient.getInetAddress().getHostAddress());
InputStream sin = someClient.getInputStream();
OutputStream sout = someClient.getOutputStream();
inputStream = new DataInputStream(sin);
outputStream = new DataOutputStream(sout);
String message;
while (true)
{
message = inputStream.readUTF();
print(message);
for (int i = 0; i < clients.size(); i++)
{
Socket client = clients.get(i);
OutputStream os = client.getOutputStream();
DataOutputStream oss = new DataOutputStream(os);
oss.writeUTF(message);
}
}
} catch (Exception e){
e.printStackTrace();
}
}
Client
socket = new Socket("0.0.0.0", 3003);
InputStream sin = socket.getInputStream();
OutputStream sout = socket.getOutputStream();
inputStream = new DataInputStream(sin);
outputStream = new DataOutputStream(sout);
sendButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(key != null && key.length() == 16)
{
Date date = new Date();
String msg = ">> " + nickname + ": " + messageField.getText()+" | " + date.getHours()+":"+date.getMinutes()+"\n";
try {
outputStream.writeUTF(Encrypt.AESEncrypt(key, msg));
} catch (IOException e1) {
e1.printStackTrace();
}
messageField.setText("");
}
else if(key == null)
JOptionPane.showMessageDialog(J_Frame, "Your key field is empty");
else if(key.length() != 16)
JOptionPane.showMessageDialog(J_Frame, "Key's length should be 16 symbols");
}
});
while (true)
{
String message;
message = inputStream.readUTF();
append("\n" + Encrypt.AESDecrypt(key, message));
}
} catch (Exception e1) {
clear();
append(">> Unable to connect to the server.");
hideButtons();
}
Every time a client connects to your server, it replaces the previous connection:
while (true)
{
someClient = serverSocket.accept();
...
}
someClient is static:
static Socket someClient;
which means it is shared by all threads.
Also, access to it is not synchronized in any way, which means changes to its value are not guaranteed to be visible to other threads.
As Peter Lawrey pointed out in the comments, the streams also need to be non-static:
static DataInputStream inputStream;
static DataOutputStream outputStream;
actually, the fact that you are always reading from the "latest" inputStream may be the main cause of the behavior you are describing.
outputStream seems to be unused, so it might be best to remove it.
In addition to that, OutputStreams may need to be flushed in order to actually send data.

Java TCP server cannot receive message from more than one client

I am going for the simplest explanation. My Java TCP project has a server and three clients.
The server has a ClientThread.
The clients each has a ServerThread and a UserThread.
The workflow is:
1. The UserThread of a client (say, client_0) gets user input and then sends a message to the server.
2. The ClientThread of the server captures the message from client_0 and sends another message to the ServerThread of a different client (say, client_1).
3. The ServerThread of client_1 then sends back another message to the ClientThread running in the server;
The message of step 3 is not reaching the server.
There are total 3 clients, say client_0, client_1 and client_2.
The original idea is that if client_0 requests the server then the server communicates with client_1 and client_2. That's why the line if(i==cid) continue; in the for loop in the server. But, if i comment out this line, the server communicates with the client_0 (which is unnecessary semantically) and the messaging problem doesn't happen. After that the server communicates with client_1 and the problem appears again.
The server can receive message from the ServerThread of the client (client_0) that sent the original request (msgToServer.println("get list");) from it's UserThread to initiate the whole process. But Server cannot get message from any other client's ServerThread even though it can send message to others and all the client programs are identical and all the ServerThreads and UserThreads should work the same eway. How is it even possible?
Server:
package serverftp;
import java.io.*;
import java.net.*;
public class ServerFTP {
static String[] id = {"cp 1","cp 2","cp 3"};
static String[] pass = {"123","456","789"};
static BufferedReader[] msgFromClient = new BufferedReader[3];
static PrintWriter[] msgToClient = new PrintWriter[3];
static InputStream[] fileFromClient = new InputStream[3];
static OutputStream[] fileToClient = new OutputStream[3];
public static void main(String[] args) throws Exception {
ServerSocket welcome = new ServerSocket(6789);
// connecting the three clients
for(int i=0; i<3; i++) {
System.out.println("Waiting for Client "+i);
Socket clientSocket;
clientSocket = welcome.accept();
while(true) {
System.out.println("Connecting Client "+i);
BufferedReader fromClient = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
PrintWriter toClient = new PrintWriter(clientSocket.getOutputStream(),true);
// get id pass from client
String clientId = fromClient.readLine();
System.out.println(clientId);
String clientPass = fromClient.readLine();
System.out.println(clientPass);
// check id pass and feedback
if(clientId.equals(id[i]) && clientPass.equals(pass[i])) {
toClient.println("ok");
msgFromClient[i] = fromClient;
msgToClient[i] = toClient;
fileFromClient[i] = clientSocket.getInputStream();
fileToClient[i] = clientSocket.getOutputStream();
break;
} else {
toClient.println("error");
}
}
ClientThread ct = new ClientThread(i);
ct.start();
System.out.println("Client "+i+" connected!");
}
welcome.close();
}
}
class ClientThread extends Thread {
int cid;
String msg;
public ClientThread(int client_id) {
cid = client_id;
try {
// telling client it's serial
ServerFTP.msgToClient[cid].println(Integer.toString(cid));
} catch(Exception ex) {
ex.printStackTrace();
}
}
#Override
public void run() {
while(true) {
try {
// get request from receiver
msg = ServerFTP.msgFromClient[cid].readLine();
if(msg.equals("get list")) {
System.out.println(cid+" "+msg);
msg = ServerFTP.msgFromClient[cid].readLine();
System.out.println(cid+" "+msg);
for(int i=0; i<3; i++) {
if(i==cid) continue;
// send sender request for file list
ServerFTP.msgToClient[i].println("give list");
System.out.println("request sent to client "+i);
// get file count from sender
msg = ServerFTP.msgFromClient[i].readLine();
System.out.println("file count caught!!!"); // THIS LINE NEVER EXECUTES
System.out.println("File count "+msg);
}
}
} catch(Exception ex) {
ex.printStackTrace();
}
}
}
}
The line System.out.println("file count caught!!!"); is never called.
Client:
package clientftp_1;
import java.io.*;
import java.net.*;
public class ClientFTP_1 {
static String[] allPaths = { "...path...\\client_1_folder",
"...path...\\client_2_folder",
"...path...\\client_3_folder"};
public static void main(String[] args) throws Exception {
InetAddress inetAddress = InetAddress.getLocalHost();
Socket server = new Socket(inetAddress,6789);
int myId;
// login phase
BufferedReader fromUser = new BufferedReader(new InputStreamReader(System.in));
BufferedReader fromServer = new BufferedReader(new InputStreamReader(server.getInputStream()));
PrintWriter toServer = new PrintWriter(server.getOutputStream(),true);
InputStream getFile = server.getInputStream();
OutputStream sendFile = server.getOutputStream();
while(true) {
System.out.println("id: ");
String msg = fromUser.readLine();
toServer.println(msg);
System.out.println("password: ");
msg = fromUser.readLine();
toServer.println(msg);
msg = fromServer.readLine();
if(msg.equals("ok")) {
System.out.println("Connection Successful!");
myId = Integer.parseInt(fromServer.readLine());
System.out.println("Client serial is: "+myId);
System.out.println("Folder path is: "+allPaths[myId]);
break;
} else {
System.out.println("Error! Try again please.");
}
}
ServerThread st = new ServerThread(allPaths[myId],fromUser,fromServer,toServer,getFile,sendFile);
st.start();
UserThread ut = new UserThread(allPaths[myId],fromUser,fromServer,toServer,getFile,sendFile);
ut.start();
}
}
class ServerThread extends Thread {
String folderPath;
String msg;
BufferedReader msgFromServer,msgFromUser;
PrintWriter msgToServer;
InputStream fileFromServer;
OutputStream fileToServer;
public ServerThread(String path,BufferedReader fromUser,BufferedReader fromServer,PrintWriter toServer,InputStream getFile,OutputStream sendFile) throws Exception {
folderPath = path;
msgFromUser = fromUser;
msgFromServer = fromServer;
msgToServer = toServer;
fileFromServer = getFile;
fileToServer = sendFile;
}
#Override
public void run() {
System.out.println("Server Thread Started");
while(true) {
try {
// receive request
msg = msgFromServer.readLine();
System.out.println("request received from server");
if(msg.equals("give list")) {
// get filenames
File folder = new File(folderPath);
File[] fileList = folder.listFiles();
int cnt = fileList.length;
System.out.println("count calculated");
// sned file count to server
msgToServer.println(Integer.toString(cnt));
System.out.println("count sent to server"); // THIS LINE PRINTS
}
} catch(Exception ex) {
ex.printStackTrace();
}
}
}
}
class UserThread extends Thread {
String folderPath;
String msg;
BufferedReader msgFromServer,msgFromUser;
PrintWriter msgToServer;
InputStream fileFromServer;
OutputStream fileToServer;
public UserThread(String path,BufferedReader fromUser,BufferedReader fromServer,PrintWriter toServer,InputStream getFile,OutputStream sendFile) throws Exception {
folderPath = path;
msgFromUser = fromUser;
msgFromServer = fromServer;
msgToServer = toServer;
fileFromServer = getFile;
fileToServer = sendFile;
}
#Override
public void run() {
System.out.println("USer Thread Started");
while(true) {
try {
// input from user
msg = msgFromUser.readLine();
if(msg.equals("get list")) {
// send request to server
msgToServer.println("get list");
msgToServer.println("fahim list");
}
} catch(Exception ex) {
ex.printStackTrace();
}
}
}
}
The line System.out.println("count sent to server"); is printed. That means the message sending line before that has executed with no problem.
I know the login system in the server is stupid. But it is 'ok' for this work. Everything explained above happens after all the clients have connected and logged in to the server.
I think I have found the problem. I was using the same socket for a client program's ServerThread and UserThread. So while the ServerThread is trying to response to the server, most probably the message is going to another different thread in the server that is listening for message (thinking the message comes from UserThread) through the same socket.

Java Socket : java.net.SocketTimeoutException: Read timed out

Hi I hope you guys are doing great.
I'm currently trying to test a service class that creates a socket connection to a print server.
Here's the service class :
public class PrintServiceImpl implements PrintService {
private static final Logger LOGGER = LoggerFactory.getLogger(PrintServiceImpl.class);
static final int TIMEOUT_MILLISECOND = 20000;
#Override
public boolean sendLabelToPrintServer(String hostname, int port, String labelData) {
Socket clientSocket = null;
DataOutputStream outToServer = null;
Boolean successful;
try {
// open the connection to the printing server
clientSocket = new Socket();
clientSocket.connect(new InetSocketAddress(hostname, port), TIMEOUT_MILLISECOND);
clientSocket.setSoTimeout(TIMEOUT_MILLISECOND);
outToServer = new DataOutputStream(clientSocket.getOutputStream());
// send data to print
outToServer.writeBytes(labelData);
BufferedReader input = new BufferedReader(new InputStreamReader(clientSocket.getInputStream(),
StandardCharsets.UTF_8));
// Read HTTP Request CHARACTER BY CHARACTER instead of line by line
while ((char) input.read() != 0 && (char) input.read() != '\r') {
LOGGER.debug("Getting print server answer.");
}
successful = true;
LOGGER.debug("Label printed.");
} catch (Exception e) {
LOGGER.error("Printing failed.", e);
successful = false;
} finally {
try {
// close connection
if (outToServer != null) {
outToServer.close();
}
if (clientSocket != null) {
clientSocket.close();
}
} catch (IOException e) {
LOGGER.error("Exception while closing DataOutputStream/ClientSocket.", e);
}
}
return successful;
}
And here's my test class. As you can see the #Before method instantiates a SocketServer on a new Thread.
public class PrintServiceImplTest {
private static final Logger LOGGER = LoggerFactory.getLogger(PrintServiceImplTest.class);
PrintServiceImpl whfPrintService = new PrintServiceImpl();
private static final String LOCALHOST = "localhost";
private static final int SERVER_PORT = 3000;
private static final String LABEL_TEXT = "This dummy text is sent to the print server";
private static final String RESPONSE = "Test Label printed correctly";
private ServerSocket server;
private Socket incommingSocket = null;
#Before
public void before() {
Thread myThread = new Thread() {
#Override
public void run() {
try {
server = new ServerSocket(SERVER_PORT);
incommingSocket = server.accept();
} catch (IOException e) {
e.printStackTrace();
}
}
};
myThread.start();
}
#After
public void after() {
try {
incommingSocket.close();
server.close();
} catch (IOException e) {
e.printStackTrace();
}
}
#Test
public void returnsTrueIfConnectionSuccessful() {
BufferedReader reader = null;
PrintWriter out = null;
BufferedReader in = null;
String line;
whfPrintService.sendLabelToPrintServer(LOCALHOST, SERVER_PORT, LABEL_TEXT);
try {
in = new BufferedReader(new InputStreamReader(incommingSocket.getInputStream()));
out = new PrintWriter(incommingSocket.getOutputStream());
reader = new BufferedReader(new InputStreamReader(incommingSocket.getInputStream()));
while ((line = reader.readLine()) != null) {
System.out.println("line : " + line);
}
out.write(RESPONSE);
out.flush();
out.close();
in.close();
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
When I run the test, I get a SocketTimoutException. It occurs when the client is reading the response from the server. This line :
while ((char) input.read() != 0 && (char) input.read() != '\r') {
So this means that the client does not receive a response. My guess is that the server does not send a correct response.
What am I missing ? thank you in advance.
Improper server->client response
You response doesn't end with a \0 or a \r.
private static final String RESPONSE = "Test Label printed correctly";
By making your response end with either of those characters, the client will escape from the loop.
private static final String RESPONSE = "Test Label printed correctly\0";
Client reads response incorrectly
The client reads the response using the following code:
while ((char) input.read() != 0 && (char) input.read() != '\r') {
Every call to input.read() returns a new byte from the network. You should call input.read() one time every while loop, and compare after it.
char c;
while (c = (char) input.read()) != -1) {
if(c == 0 || c == '\r') {
break;
}
}
Client to server message has no proper ending
Messages send from the client to server have no ending, the server reads until the socket input is closed, but the client never closes the socket.
// send data to print
outToServer.writeBytes(labelData);
After you wrote those bytes, call socket.shutdownOutput() to signal end of file to the other party.
// send data to print
outToServer.writeBytes(labelData);
clientSocket.shutdownOutput();

Java Sockets: Client and Server. Server not responding when receiving data from a radio button

Hello I need some quick help with this Server/Client socket program I am writing in Java. Everything works as intended when entering standard input on the client side. The server responds with the correct data every time. But when I send data to the Server using the actionListener, nothing is returned. The data is being sent over and read by the Server and can be printed server-side, it just won't come back to the Client.
So this must be an issue with the formatting or type of data being sent from the actionListener (I don't know enough about streams unfortunately), or it is an issue with the stream on the server side?
Any help is most appreciated!
public class Serv {
public static void main(String[] args) throws IOException {
ServerSocket serverSocket = null;
try {
serverSocket = new ServerSocket(8889);
System.out.println("Waiting for client...");
} catch (IOException e) {
System.err.println("Could not listen on port: 8889.");
System.exit(1);
}
Socket clientSocket = serverSocket.accept();
BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true);
String inputLine, outputLine;
Protocol p = new Protocol();
out.println("welcome");
while ((inputLine = in.readLine()) != null) {
outputLine = p.processInput(inputLine);
System.out.println("Input: "+inputLine + "\nOutput: "+outputLine);
out.println(outputLine);
if (outputLine.equals("Exit")) { break; }
}
out.close();
in.close();
clientSocket.close();
serverSocket.close();
}
}
public class Cl extends JFrame {
public static PrintWriter out = null;
public static String fromUser;
public static void Client() {
saveAnswer.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ButtonModel b = group.getSelection();
if (b.getActionCommand() == "A") { sendAnswer = radioA.getText(); }
if (b.getActionCommand() == "B") { sendAnswer = radioB.getText(); }
if (b.getActionCommand() == "C") { sendAnswer = radioC.getText(); }
String data = "÷" + sendAnswer;
out.println(data);
}
});
}
public static void main(String[] args) throws IOException {
Socket Socket = null;
BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
boolean checkOpen = false;
Socket clientS = new Socket("localhost", 8889);
out = new PrintWriter(clientS.getOutputStream(), true);
BufferedReader in = new BufferedReader(new InputStreamReader(clientS.getInputStream()));
String fromServer;
while ((fromServer = in.readLine()) != null) {
if (fromServer.startsWith("®")) {
if (checkOpen == false) { Cl.Client(); checkOpen = true; }
qA.splitter(fromServer);
}
if (fromServer.equals("Exit")) { break; }
fromUser = stdIn.readLine();
if (fromUser != null) {
System.out.println("Client: " + fromUser);
out.println(fromUser);
}
else { System.out.println("trouble"); }
}
out.close();
in.close();
stdIn.close();
Socket.close();
}
}
In the server, you're sending one line and then reading from the client until EOS.
In the client, you're reading from the server until EOS and then sending whatever the user types.
Your protocol doesn't make sense. All you have here is a deadlock.
You might need to do out.flush() after writing the response on the server side.

Socket server stuck

I'm trying to make a server/client to send text from client to server then sending back an ok message or something similar back to the client, but for some error that I can't see, either the server gets stuck right before sending the ok back to the client, or the client does not receive the message (I think it's the first one though).
Any help is appreciated.
This is the server code:
class ActiveServer extends Thread {
InputStream inStream;
OutputStream outStream;
public ActiveServer(InputStream inStream, OutputStream outStream) {
this.inStream = inStream;
this.outStream = outStream;
}
#Override
public void run() {
boolean ret = false;
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inStream));
PrintWriter writer = new PrintWriter(outStream);) {
String line = null;
while((line = reader.readLine()) != null) {
String[] str = line.split(";");
line = null;
switch (str[0]) {
case "insert" : //ret = SQLOptions.insert(str[1], str[2]);
System.out.println(str[1]);
break;
}
writer.print(ret);
writer.flush();
// As far as i can see it gets stuck at the end of this while, but I don't know why.
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
public class Server {
private static final int PORT = 39165;
public static void main(String[] args) {
try (ServerSocket server = new ServerSocket(PORT);) {
System.out.println("Servidor online");
ExecutorService service = Executors.newFixedThreadPool(10);
while (true) {
Socket client = server.accept();
InetAddress ip = client.getInetAddress();
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
Date time = new Date();
System.out.print(sdf.format(time));
System.out.println(" " + ip + " connected");
InputStream inStream = client.getInputStream();
OutputStream outStream = client.getOutputStream();
service.execute(new ActiveServer(inStream,outStream));
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
And here goes the client code:
public class Telnet {
static Console console = System.console();
public static void connect(String ip, String port) {
try(Socket socket = new Socket(ip, Integer.parseInt(port));
PrintWriter writer = new PrintWriter(socket.getOutputStream());
BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));) {
String msg = null;
while(true) {
msg = console.readLine();
writer.println(msg);
writer.flush();
if (msg.equals(".quit")) {
System.out.println("Exiting...");
break;
}
String input = reader.readLine();
System.out.println(input);
}
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
if(args.length < 2) {
err.println("Telnet <ip> <port>");
return;
}
if (console == null) {
err.println("A console is not available");
return;
}
connect(args[0], args[1]);
}
}
On the server side, you write the response without a terminating newline:
writer.print(ret);
But on the client side, you read until the end of line:
String input = reader.readLine();
The documentation for BufferedReader#readLine says:
Reads a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed.
Thus, the client will wait forever for the newline sequence which the server will never send.

Categories

Resources