hey all, this is the specification of my project. the server waits for client on socket x. as hte client connects, the server shud accept it and create a new socket for client and go back wait for clients.i can't use mutiple thread for each client. i mean, server waits on socket x, once client connects the server creates a new socket y to handle this client and wait for another client. how do i do this?. and if i store the output stream for each client in a vector, can i broadcast to all clients from server by iterating thru the vector. is this the best way? as of now, my implementation is that server accepts all the clients on one socket only and when ever i try to broadcast some message to all clients, it doesn't work so properly. any help will be appreciated.. thank you lucy..
posted 15 years ago
hello all, a small update. could some one pls take a look at my code and point out the run time errors. specs are, the server has 2 threads: one main and other servant thread. the main thread waits for connection from clients and opens a TCP socket connection. the servant thread waits for UDP packet from client and as soon as it recieves a packet, it sends the message contained in the packet tp all clients using the TCP connection. so, the output stream for each client is held in data structure, so my servant thread iterates thru it and sends the message to all clients. server code snippets
when 2 clients log in, the message is received by the client that sends it but other client doesn't. but if other client sends any message, it prints the message what other client has sent previously. i mean, message from client 1: hello server, Echo on client 1: from server: hello server on client 2: (its nothing) now message from client 2: i am client 2 Echo on client 1: (its nothing) on client 2: from server: hello server so is this a problem on client side or server side? my clien code...
could some one pls show where is my blunder? thank you lucy...