|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Article Dicussion: Asynchronous Socket Utility Classes – Part I
If you have any questions or comments about this article please post them here.
This forum post relates to this article |
|
#2
|
|||
|
|||
|
the reader's question about c# client + java server
hello
i am a java programmer,i am now studying c#,i find this article about asynchrous socket is very practical,so i study it.now i have finish the part1(that is a clientside). it works well to connect to any website(just as "www.continuumtechnologycenter.com"),then i try to coorperate the asynchronous c# socket client with a simple java socket server(that is a echo server),the java server code as following: ServerSocket serverSocket = new ServerSocket(10000); while (true) { Socket socket = serverSocket.accept(); PrintWriter out = new PrintWriter(socket.getOutputStream(), true); BufferedReader in=new BufferedReader(new InputStreamReader(socket.getInputStream())); out.println("you have connected"); String input; while((input=in.readLine())!=null){ System.out.println(input); out.println(input); } System.out.println("out of while loop"); i modify the "TestClient()" in the client side as following: CSocketClient pSocketClient=new CSocketClient(10240,null, new CSocketClient.MESSAGE_HANDLER(MessageHandlerClient ), new CSocketClient.CLOSE_HANDLER(CloseHandler), new CSocketClient.ERROR_HANDLER(ErrorHandler)); pSocketClient.Connect("localhost",10000); pSocketClient.Send("hello world"); Console.ReadLine(); pSocketClient.Disconnect(); Console.ReadLine(); pSocketClient.Dispose(); then i start the java server,and c# client,from the client side console,i can see: you have connected from the server side console,the following is printed: hello world out of while loop it mean that the java server can send "you have connected" to c# client,and the client can send "hello world" to the server,the server side can echo the "hello world" back to the client,but why "hello world" that is echoed back from server can't be printed in the client side console?i wonder if the asynchronous c# socket can works well with the java socket? help me,thank you!! |
![]() |
| Viewing: Dev Articles Community Forums > Programming > Programming Tools > Article Dicussion: Asynchronous Socket Utility Classes – Part I |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|