Network Programming in java

@kingadnan (1541)
January 18, 2007 4:25pm CST
I have to create a client/server project, so i need information about network programming in java, please explain me network programming and how can i communicate with client and server? please tell me....and please share some sample codes also. thanks
1 response
• Egypt
21 Jan 07
u must first understand the client/server model. It means simply that the server is there waiting to any client to connect to it. this means that the server will be waiting and the client will connect directly. There are 2 kinds of sockets, ServerSockets and normal Sockets. ServerSockets are used by servers to listen to incoming connections from clients, there is a method in it that u should call and it will keep listening and will not return until a new client is connected, then u should extract a normal socket from the server socket and get Input/Output streams from both sockets and send data u want. When u write something in the output stream of the server it will it will go to the input stream of the client, and vice versa. when a new client comes, u want the server to continue listening for other clients, so u should start a new thread and pass the client to this thread, in which u should communicate between client and server. there are a good chatting program that implements all this