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. winsock connect problem

winsock connect problem

Scheduled Pinned Locked Moved C / C++ / MFC
questionsysadminhelptutorial
8 Posts 4 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.
  • M Offline
    M Offline
    minihotto
    wrote on last edited by
    #1

    I met a problem. I have a server and a client. Client connect to server. It works and client can send message to server. But how can I send message from server to client? I try to let server connect to client, but it says it already connected. How could I let server send message to client,too? Can somebody give me an example? Thanks a lot. minihotto

    V L C 3 Replies Last reply
    0
    • M minihotto

      I met a problem. I have a server and a client. Client connect to server. It works and client can send message to server. But how can I send message from server to client? I try to let server connect to client, but it says it already connected. How could I let server send message to client,too? Can somebody give me an example? Thanks a lot. minihotto

      V Offline
      V Offline
      viliam
      wrote on last edited by
      #2

      Server can not connect to client. It can - of course send data as a reply but can not initialize connection. You have to open another port (socket) to listen. It is mean your application must have both parts - server and client. (client has to also listen - to be possible to connected it by "server")

      viliam

      M 1 Reply Last reply
      0
      • M minihotto

        I met a problem. I have a server and a client. Client connect to server. It works and client can send message to server. But how can I send message from server to client? I try to let server connect to client, but it says it already connected. How could I let server send message to client,too? Can somebody give me an example? Thanks a lot. minihotto

        L Offline
        L Offline
        led mike
        wrote on last edited by
        #3

        http://www.codeproject.com/internet/[^]

        led mike

        M 1 Reply Last reply
        0
        • L led mike

          http://www.codeproject.com/internet/[^]

          led mike

          M Offline
          M Offline
          minihotto
          wrote on last edited by
          #4

          I try to download the file. But it's a webpage.

          L 1 Reply Last reply
          0
          • M minihotto

            I try to download the file. But it's a webpage.

            L Offline
            L Offline
            led mike
            wrote on last edited by
            #5

            Yes it is a web page listing articles that contain sample/example Socket code. Please "READ" the web page.

            led mike

            M 1 Reply Last reply
            0
            • L led mike

              Yes it is a web page listing articles that contain sample/example Socket code. Please "READ" the web page.

              led mike

              M Offline
              M Offline
              minihotto
              wrote on last edited by
              #6

              Thanks for your help. It's a stupid question. I forget to login.><

              1 Reply Last reply
              0
              • V viliam

                Server can not connect to client. It can - of course send data as a reply but can not initialize connection. You have to open another port (socket) to listen. It is mean your application must have both parts - server and client. (client has to also listen - to be possible to connected it by "server")

                viliam

                M Offline
                M Offline
                minihotto
                wrote on last edited by
                #7

                I have an application that have two threads - listen(recv) & connect(send) but I can send once, I cant send twice.

                1 Reply Last reply
                0
                • M minihotto

                  I met a problem. I have a server and a client. Client connect to server. It works and client can send message to server. But how can I send message from server to client? I try to let server connect to client, but it says it already connected. How could I let server send message to client,too? Can somebody give me an example? Thanks a lot. minihotto

                  C Offline
                  C Offline
                  Chipperm
                  wrote on last edited by
                  #8

                  Is your server/client system using SOCK_DGRAM or SOCK_STREAM. if you are using SOCK_STREAM then once the connection is accepted using the accept function there should be a socket variable that the client is connected to. SOCKET server; //assume already in listen state SOCKET client = accept(server, ...); use the client variable to send messages back to the client machine like the following: send(client, ...);

                  Chipper Martin

                  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