Click here to Skip to main content
15,923,120 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionInterfacing Pin
benjnp21-Sep-05 4:42
benjnp21-Sep-05 4:42 
AnswerRe: Interfacing Pin
Bob Stanneveld21-Sep-05 5:30
Bob Stanneveld21-Sep-05 5:30 
GeneralRe: Interfacing Pin
benjnp21-Sep-05 14:45
benjnp21-Sep-05 14:45 
GeneralRe: Interfacing Pin
Bob Stanneveld21-Sep-05 20:14
Bob Stanneveld21-Sep-05 20:14 
QuestionWindows Procedure Pin
benjnp21-Sep-05 4:36
benjnp21-Sep-05 4:36 
AnswerRe: Windows Procedure Pin
Blake Miller21-Sep-05 5:05
Blake Miller21-Sep-05 5:05 
AnswerRe: Windows Procedure Pin
Bob Stanneveld21-Sep-05 5:34
Bob Stanneveld21-Sep-05 5:34 
QuestionWhy does a non-blocking socket get blocked when call connect? Pin
alvaro21-Sep-05 4:32
alvaro21-Sep-05 4:32 
Hi all,

I'm facing an odd behaviour in a client application that I'm currently working on. Let me put you in the picture: I create a socket and then call ioctlsocket to set it to non-bloking mode. After this I try to stablish a connection to a server through this socket, so far so good.When I call 'connect' it is supposed to return the control inmendiately with an error such as WSAEWOULDBLOCK but this does not happen at all an it hangs for a while.

    <br />
    sockaddr_in server          ={0};<br />
    SOCKET sClient              = 0;<br />
    <br />
<br />
    // fill in server data structure<br />
    server.sin_family = AF_INET;<br />
    server.sin_port = htons(ESEP_SERVER_PORT_1);<br />
    server.sin_addr.S_un.S_addr  = htonl(ulIP);<br />
<br />
    <br />
    // Create a client socket<br />
    if ((sClient = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP)) == INVALID_SOCKET )<br />
    {<br />
        FormatError();           <br />
        return ESEP_ERR_CREATE_SOCKET;<br />
    }<br />
      <br />
    fd_set fdWrite          ={0};<br />
    TIMEVAL time            ={0};<br />
    int iRC                 = 0;<br />
    unsigned long ulMode    = 0; // Socket mode<br />
<br />
    <br />
    // make the socket non-blocking<br />
    ulMode = 1;<br />
    if (ioctlsocket(sClient, FIONBIO, &ulMode) == SOCKET_ERROR)<br />
    {<br />
        FormatError();<br />
        return ESEP_ERR_CONNECT;<br />
    }<br />
<br />
    // Set up the necessary structures to<br />
    // manage the timeout in the connection attempt<br />
    FD_ZERO(&fdWrite);<br />
    FD_SET(sClient,&fdWrite);<br />
    time.tv_usec = ESEP_CONNECT_TIMEOUT; // timeout in milliseconds<br />
<br />
    // try to connect to the peer server<br />
    iRC = connect(sClient,(SOCKADDR *)&server, sizeof(server));<br />
    // Check if the timeout has elapsed without success<br />
    if ((iRC == SOCKET_ERROR) && ( WSAGetLastError() == WSAEWOULDBLOCK ))<br />
    {<br />
        if ( select(0,NULL,&fdWrite,NULL,&time) <= 0 )<br />
        {<br />
            FormatError();<br />
            return ESEP_ERR_CONEX_REJECTED;<br />
        }<br />
    }<br />


The most curious thing is that this behaviour only takes place in some particular computers because if I run the application in my development machine or in some other machine everything works absolutely right.

I have taken two different machines with the same configuration (everything is the same, they're almost clones) and it works in one system but it doesn't in the other. Has anybody ever had a problem like this? Any reasonable explanation? I'm a bit puzzled because I'm not able to guess why this happens, I've been looking for something in differents forums and dicussion boards but I found nothing. Could you help me please?
QuestionLength of VARIANT V_BSTR Pin
Kreatief21-Sep-05 4:23
Kreatief21-Sep-05 4:23 
AnswerRe: Length of VARIANT V_BSTR Pin
Steen Krogsgaard21-Sep-05 23:51
Steen Krogsgaard21-Sep-05 23:51 
GeneralRe: Length of VARIANT V_BSTR Pin
Kreatief22-Sep-05 0:32
Kreatief22-Sep-05 0:32 
GeneralRe: Length of VARIANT V_BSTR Pin
Steen Krogsgaard22-Sep-05 0:49
Steen Krogsgaard22-Sep-05 0:49 
GeneralRe: Length of VARIANT V_BSTR Pin
Kreatief22-Sep-05 1:10
Kreatief22-Sep-05 1:10 
GeneralRe: Length of VARIANT V_BSTR Pin
Steen Krogsgaard22-Sep-05 1:26
Steen Krogsgaard22-Sep-05 1:26 
GeneralRe: Length of VARIANT V_BSTR Pin
Steen Krogsgaard22-Sep-05 1:33
Steen Krogsgaard22-Sep-05 1:33 
GeneralRe: Length of VARIANT V_BSTR Pin
Kreatief22-Sep-05 2:37
Kreatief22-Sep-05 2:37 
GeneralRe: Length of VARIANT V_BSTR Pin
Steen Krogsgaard22-Sep-05 2:41
Steen Krogsgaard22-Sep-05 2:41 
QuestionDisplay colour depth - what's the point? Pin
Taka Muraoka21-Sep-05 3:42
Taka Muraoka21-Sep-05 3:42 
AnswerRe: Display colour depth - what's the point? Pin
Chris Losinger21-Sep-05 4:18
professionalChris Losinger21-Sep-05 4:18 
GeneralRe: Display colour depth - what's the point? Pin
Taka Muraoka21-Sep-05 4:33
Taka Muraoka21-Sep-05 4:33 
GeneralRe: Display colour depth - what's the point? Pin
Chris Losinger21-Sep-05 4:39
professionalChris Losinger21-Sep-05 4:39 
GeneralRe: Display colour depth - what's the point? Pin
Taka Muraoka21-Sep-05 5:00
Taka Muraoka21-Sep-05 5:00 
GeneralRe: Display colour depth - what's the point? Pin
Shog921-Sep-05 6:12
sitebuilderShog921-Sep-05 6:12 
GeneralRe: Display colour depth - what's the point? Pin
El Corazon21-Sep-05 6:15
El Corazon21-Sep-05 6:15 
GeneralRe: Display colour depth - what's the point? Pin
Taka Muraoka21-Sep-05 6:23
Taka Muraoka21-Sep-05 6:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.