I have one problem, I learn how work with socket and I write programm with next code :
import java.net.*;
import java.io.*;
import java.util.*;
public class Client extends Thread{
public static void main(String args[])
{
try
{
Socket s = new Socket(args[0],Integer.parseInt(args[1]));
BufferedReader br=new BufferedReader(new InputStreamReader(System.in,"CP866"));
String str;
str=br.readLine();
str = str+"\n"+s.getInetAddress().getHostAddress()
+":"+s.getLocalPort();
PrintWriter pw = new PrintWriter(new OutputStreamWriter(s.getOutputStream()));
pw.println(str);
pw.flush();
while(true){
str=null;
if((str=br.readLine())==null)
break;
str = str+"\n"+s.getInetAddress().getHostAddress()
+":"+s.getLocalPort();
System.out.println(str);
pw.print(str);
pw.flush();
}
}
catch(Exception e)
{System.out.println("init error: "+e);}
}
}
Programm of server-side just print obtained message, first message normal print, but next message print in format :, when I cut 25-26 line - message not sent or not obtained.
Why?