Error with accept();

This is a discussion on Error with accept(); within the Networking/Device Communication forums, part of the General Programming Boards category; What do you mean by 'two processes running at teh same time'. Do you mean your client and server run ...

  1. #31
    Registered User
    Join Date
    Nov 2002
    Posts
    491
    What do you mean by 'two processes running at teh same time'. Do you mean your client and server run at the same time? If so just run each of them seperatly.
    You dont' need threads for any of what you are doing and threads are quite complex and will only make things worse. Look up select as I already suggested, and please be more complete in what you mean by "two processes running at the same time".

  2. #32
    I am me, who else?
    Join Date
    Oct 2002
    Posts
    250
    You don't need to have 2 threads running for reading/sending. You can use non-blocking sockets for this. As orbitz explained above, threads are not necessary unless you need more processing done with other parts of your server. Honestly you shouldn't think of being multi-threaded until you can get the reading/writing w/o blocking.

    If writing for windows, check out WSAAsyncSelect, or use Select() from
    Beej's Guide . Orbitz is also right about defining what you mean, because from what I see, you want to run a server and client at the same time from the same app? Do you mean something else?

  3. #33
    essence of digital xddxogm3's Avatar
    Join Date
    Sep 2003
    Posts
    589
    Another question on sockets.
    Can you have a socket as a public object in a class?

    Code:
    class SocketProgram
    {
    public:
         SocketProgram();
         ~SocketProgram();
    
         SOCKET localSocket;
         sockaddr_in localSockAddr;
    };
    "Hence to fight and conquer in all your battles is not supreme excellence;
    supreme excellence consists in breaking the enemy's resistance without fighting."
    Art of War Sun Tzu

  4. #34
    Registered User
    Join Date
    Nov 2002
    Posts
    491
    Of course, why wouldn't you be able to?

  5. #35
    essence of digital xddxogm3's Avatar
    Join Date
    Sep 2003
    Posts
    589
    and another question on sockets.

    what is the scope of the sockaddr_in?
    Once it has been declared, what scope does it have?
    "Hence to fight and conquer in all your battles is not supreme excellence;
    supreme excellence consists in breaking the enemy's resistance without fighting."
    Art of War Sun Tzu

  6. #36
    Registered User
    Join Date
    Nov 2002
    Posts
    491
    The same scope as any other variable. The scope rules do not apply special for sockaddr_in.

Page 3 of 3 FirstFirst 123
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Create program that accept modules
    By rluceac in forum C++ Programming
    Replies: 16
    Last Post: 04-11-2009, 03:11 PM
  2. could not accept socket
    By Elkvis in forum Linux Programming
    Replies: 3
    Last Post: 02-26-2008, 07:42 AM
  3. Using a single socket for accept() as well as connect()?
    By nkhambal in forum Networking/Device Communication
    Replies: 3
    Last Post: 10-20-2005, 05:43 AM
  4. async Client/Server app, accept() stalls?
    By JaWiB in forum Networking/Device Communication
    Replies: 14
    Last Post: 01-31-2005, 04:59 PM
  5. Make accept() stop
    By b00l34n in forum Networking/Device Communication
    Replies: 28
    Last Post: 12-20-2004, 05:50 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21