OT: sockets

Discussion in 'C++' started by Gernot Frisch, Sep 14, 2004.

  1. Hi,

    sorry, I didn't know where else to go...

    I want to make a client/server program. The server should wait for
    incoming messages, but if no messages are present, the recvfrom
    function should return immediately. Any ideas? Should I start a worker
    thread that stores messages received on a stack?

    I'm new to sockets, can you point me to a good source?

    Thank you,

    --
    -Gernot
    int main(int argc, char** argv) {printf
    ("%silto%c%cf%cgl%ssic%ccom%c", "ma", 58, 'g', 64, "ba", 46, 10);}
    Gernot Frisch, Sep 14, 2004
    #1
    1. Advertising

  2. Gernot Frisch

    Sivert Berg Guest

    Re: sockets

    "Gernot Frisch" <> skrev i melding
    news:...
    > Hi,
    >
    > sorry, I didn't know where else to go...
    >
    > I want to make a client/server program. The server should wait for
    > incoming messages, but if no messages are present, the recvfrom
    > function should return immediately. Any ideas? Should I start a worker
    > thread that stores messages received on a stack?
    >
    > I'm new to sockets, can you point me to a good source?
    >
    > Thank you,
    >
    > --
    > -Gernot
    > int main(int argc, char** argv) {printf
    > ("%silto%c%cf%cgl%ssic%ccom%c", "ma", 58, 'g', 64, "ba", 46, 10);}
    >
    >


    This is a bit platfrom dependent, but I think that select() is used in both
    Winsock and BSD so do this:
    1) Make a non-blocking socket.
    2) Run the RecvFrom() command.
    3) Run the select() command to check if it is anything to read. Did
    something similar with connect(). Should work. And next time post in a
    group that is dedicated to the OS or whatever your runing.

    Sivert Berg
    Sivert Berg, Sep 14, 2004
    #2
    1. Advertising

  3. Gernot Frisch wrote:

    > Hi,
    >
    > sorry, I didn't know where else to go...
    >
    > I want to make a client/server program. The server should wait for
    > incoming messages, but if no messages are present, the recvfrom
    > function should return immediately. Any ideas? Should I start a worker
    > thread that stores messages received on a stack?
    >
    > I'm new to sockets, can you point me to a good source?


    Try using the ACE framework (http://www.cs.wustl.edu/~schmidt/ACE.html).
    It's perfect for networked programming.

    lothar
    Lothar Werzinger, Sep 15, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jeff
    Replies:
    0
    Views:
    1,498
  2. Rick
    Replies:
    0
    Views:
    1,126
  3. Gaurav Khanna [.NET MVP]

    Re: System.Net.Sockets.Tcplistener

    Gaurav Khanna [.NET MVP], Jul 25, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    3,413
    Gaurav Khanna [.NET MVP]
    Jul 25, 2003
  4. Didatus

    UNIX Domain Sockets

    Didatus, Aug 18, 2003, in forum: Perl
    Replies:
    1
    Views:
    1,521
  5. Iceberg

    Carriage Returns and sockets

    Iceberg, Sep 6, 2003, in forum: Perl
    Replies:
    1
    Views:
    1,129
    Iceberg
    Sep 6, 2003
Loading...

Share This Page