Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. socket question

socket question

Scheduled Pinned Locked Moved C / C++ / MFC
helpsysadminxmltutorialquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nahitan
    wrote on last edited by
    #1

    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

    R A 2 Replies Last reply
    0
    • N nahitan

      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

      R Offline
      R Offline
      Roger Stoltz
      wrote on last edited by
      #2

      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!

      1 Reply Last reply
      0
      • N nahitan

        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

        A Offline
        A Offline
        abbiyr
        wrote on last edited by
        #3

        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

        N 1 Reply Last reply
        0
        • A abbiyr

          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

          N Offline
          N Offline
          nahitan
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups