Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Regarding Window Sockets

Posted on 1999-06-27
Medium Priority
Last Modified: 2010-04-02
Hi !
My client application is connecting to a server using connect command. The server then accepts the connection.
I want that as soon as server accepts the connection my client got the notification of that, in a messsage box (say) telling that "connection has been accepted". How can I do that.

Regards :-

Question by:sun307
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2

Expert Comment

ID: 1198594
I suppose that u'r using SOCKET's and not a lib or something like that.
using the following row will tell you whether u'r connected or not.
Socket s;
// Some init for the socket....
     // Not connected
    // Connected


Author Comment

ID: 1198595
U r right i am using win32 sockets api but i want that when server accepts the connection using accept() command, the client should get notified immediately.

Expert Comment

ID: 1198596
Well, u do..... When you issue "::connect", what happends on the server is that he get's notified about your existens in his que and he will issue the accept-command.
if he doesnt do this ( uses accept on your request ) then your connect-row will return an socket error, something like connection refused, I don't remember. So you'll get notified as soon as the server uses "accept", by checking the return-result from connect.
Connect doesnt return until: 1) he reaches timeout or 2) the server accepts.

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

ID: 1198597
Well, if you rejected my answer....tell me then what was wrong. ok?

Author Comment

ID: 1198598
Hi !

First i want to explain a bit about the application.

The client connects to the server using connect command.
The server then gets a dialog box asking the user whether he wants to accept the connection or not. if presses Yes then the connection is accepted using "Accept" command otherwise nothing happens.

the solution proposed by u only tells that whether the connect command is successful or not and it always returns 0 whether the server accepts the connection or not. That is not what i want.

If the server accepts the connection after 10 seconds of the appearance of dialog box then the client should be notified after 10 seconds when the connection is accepted.

If u still have the solution to this then propose an answer again and i will accept that.

Regards :-


Accepted Solution

ajosefsson earned 80 total points
ID: 1198599
// Clientside:
int iRes=::connect(....);
// this means that the server didn't accept your connect-request
   int iCode=WSAGetLastError();
      // Attempt to connect timed out without establishing a connection.
     // The attempt to connect was forcefully rejected.
   // U'r connected...

or if u'r using "WSAAsyncSelect" you will be notified by through the message: "FD_CONNECT"

// Serverside:

Does this solve your problem?

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question