socket question
-
I have one server and three clients, Messages come as XML format from client1 and I have to send it to client2 (without knowing the content of the message)through server and then send back the ACK to client1 when client2 gives it to server, Now the problem is that if client1 sends a particular message to server(say if the message is sign on request)I should send it to client3 through rotor and internet and then get the response back from cliet3 and send it to client1 and client2(:sigh:) I have a socket class written for this problem but I do not know how to handle the WHOLE THING. I guess I hould check the content of the message that comes from client1 in my APIClass and then use different sockets to send it to different clients. Please help me to solve this issue :confused: Nahitannahi@yahoo.ca
-
I have one server and three clients, Messages come as XML format from client1 and I have to send it to client2 (without knowing the content of the message)through server and then send back the ACK to client1 when client2 gives it to server, Now the problem is that if client1 sends a particular message to server(say if the message is sign on request)I should send it to client3 through rotor and internet and then get the response back from cliet3 and send it to client1 and client2(:sigh:) I have a socket class written for this problem but I do not know how to handle the WHOLE THING. I guess I hould check the content of the message that comes from client1 in my APIClass and then use different sockets to send it to different clients. Please help me to solve this issue :confused: Nahitannahi@yahoo.ca
Sounds like you have to define a nifty little protocol of your own, where you can distinguish the different message types from each other. The payload of each packet could be the XML info. Or perhaps I didn't understand your problem correctly... :~ Hope it helps anyway -- Roger
It's supposed to be hard, otherwise anybody could do it!
-
I have one server and three clients, Messages come as XML format from client1 and I have to send it to client2 (without knowing the content of the message)through server and then send back the ACK to client1 when client2 gives it to server, Now the problem is that if client1 sends a particular message to server(say if the message is sign on request)I should send it to client3 through rotor and internet and then get the response back from cliet3 and send it to client1 and client2(:sigh:) I have a socket class written for this problem but I do not know how to handle the WHOLE THING. I guess I hould check the content of the message that comes from client1 in my APIClass and then use different sockets to send it to different clients. Please help me to solve this issue :confused: Nahitannahi@yahoo.ca
Hi there.
----Client 1
Server --------+---Client 2 ------ ----Client 3
Two solutions come to mind. My assumptions . your server is acting as a proxy - i.e. clients 1,2,3 only talk to the server, not directly to each other. . client 1 is only ever a socket client, it does not listen for a connection . client 2,3 have sockets open waiting for a connection from the server. Firstly, if you want one socket listening on your server, you will have to inspect the messages. No sign message The steps, . Client 1 sends message . Server (starting a new thread for the connection) inspects message and opens a connection a connection to client 2 and sends message to client 2 . Client 2 ACKS message to Server . Server ACKS message to Client 1 Sign on request message . Client 1 sends message . Server (starting a new thread for the connection) inspects message and opens a connection a connection to client 3 and sends message to client 3 . Client 3 signs and returns to the message to the server. . Server opens a connection a connection to client 2 and sends signed message to client 2 . Client 2 ACKS message to Server . Server ACKS message to Client 1 Alternatively, if you use two different sockets on your server, one for signed messages, one for normal messages, then you will not have to inspect the messages on the server. Remember to use threads when accepting your socket connections. Hope this helps concrete your design. Cheers
-
Hi there.
----Client 1
Server --------+---Client 2 ------ ----Client 3
Two solutions come to mind. My assumptions . your server is acting as a proxy - i.e. clients 1,2,3 only talk to the server, not directly to each other. . client 1 is only ever a socket client, it does not listen for a connection . client 2,3 have sockets open waiting for a connection from the server. Firstly, if you want one socket listening on your server, you will have to inspect the messages. No sign message The steps, . Client 1 sends message . Server (starting a new thread for the connection) inspects message and opens a connection a connection to client 2 and sends message to client 2 . Client 2 ACKS message to Server . Server ACKS message to Client 1 Sign on request message . Client 1 sends message . Server (starting a new thread for the connection) inspects message and opens a connection a connection to client 3 and sends message to client 3 . Client 3 signs and returns to the message to the server. . Server opens a connection a connection to client 2 and sends signed message to client 2 . Client 2 ACKS message to Server . Server ACKS message to Client 1 Alternatively, if you use two different sockets on your server, one for signed messages, one for normal messages, then you will not have to inspect the messages on the server. Remember to use threads when accepting your socket connections. Hope this helps concrete your design. Cheers
Tnx for the help, Here what I have is that in the code I have a messagetype as PKT_MSGTYPE_FORM_DATA which I receive from client1 (a small machine programmed by micro C a wireless thing working like a intract machine) my program recognizes this Form if it's value is 0F(Hex) and if it's first byte (the string) is number 04H it should send the packet to client3 otherwise send to client2, could you help me to write the C code for this problem? also as I am new in socket programming, I am not sure how to handle all the socket thread stuff SOS tnx a lot! nahitannahi@yahoo.ca