Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-08

FPCONNECT NOT WORKING?

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

epergola

I am using lnet (non visual) with Lazarus,
and in the connect process, lnet calls
fpConnect(FHandle, psockaddr(@FAddress), SizeOf(FAddress)); fpconnect is a FreePascal function (I could not step into it with F7). The problem is that whether it actually connects (passing correct address and correct port)
or not (passing correct address but wrong port) it always returns -1. Why?
What can I check to see if a connection is ACTUALLY established between the (Delphi)
ServerSocket and the Lazarus Client socket? (My Delphi serversocket writes to a memo all
messages received and sent, so i know that with the WRONG port nothing was sent nor
received since when connected the memo show "Client Connected" and "Accepted").
I saw a post dated 2008 asking about this error (bug?), but I saw no answer. Anybody can help?
Thans

View this message in context: http://www.nabble.com/FPCONNECT-NOT-WORKING--tp25073238p25073238.html Sent from the Free Pascal - General mailing list .

Reply by email

Rainer Stratmann
to epergola

more information
linux? windows?
blocking or nonblocking sockets?

epergola wrote 19 lines
I am using lnet (non visual) with Lazarus, and in the connect process, lnet calls fpConnect(FHandle, psockaddr(@FAddress), SizeOf(FAddress)); fpconnect is a FreePascal function (I could not step into it with F7). The problem is that whether it actually connects (passing correct address and correct port) or not (passing correct address but wrong port) it always returns -1. Why? What can I check to see if a connection is ACTUALLY established between the (Delphi) ServerSocket and the Lazarus Client socket? (My Delphi serversocket writes to a memo all messages received and sent, so i know that with the WRONG port nothing was sent nor received since when connected the memo show "Client Connected" and "Accepted"). I saw a post dated 2008 asking about this error (bug?), but I saw no answer. Anybody can help? Thans

Reply by email

epergola
to Rainer Stratmann

Sorry, you are right.
I am using non blocking sockets (lNet library), no visual package, on the wince-arm
side, attempting to communicate with a non blocking (Delphi) socket on my PC.
Everything works fine (did a lot of data send and receive) except that fpconnect with correct address (PC computer name) and port number still returns
-1.
Hence, this lines in the lNet lib (modified by me) if SetupSocket(APort, Address) then begin

    i:=fpConnect(FHandle, psockaddr(@FAddress), SizeOf(FAddress));
    if i>=0 then
      FConnecting := True;
    Result := FConnecting;
  end;

will always return false for the Connect function. The original code in lNet was
if SetupSocket(APort, Address) then begin

    pConnect(FHandle, psockaddr(@FAddress), SizeOf(FAddress));
    FConnecting := True;
    Result := FConnecting;
  end;

which always returned TRUE, even when fpconnect fails; Any idea as to what I may check (beside the return code of fpconnect which does not work)
to see if the conneccion actually took place?
Thanks

more information
linux? windows?
blocking or nonblocking sockets?

View this message in context: http://www.nabble.com/FPCONNECT-NOT-WORKING--tp25073238p25083432.html Sent from the Free Pascal - General mailing list .

Reply by email

Rainer Stratmann
to epergola

if you use non-blocking sockets, you have to repeat the fpconnect call as i know. until the connection is ok.
i did it also for my application this way.
there exist also other ways to see if the connection is ok after the connect call...
but i don't know if they are compatible to arm system

epergola wrote 32 lines
Sorry, you are right. I am using non blocking sockets (lNet library), no visual package, on the wince-arm side, attempting to communicate with a non blocking (Delphi) socket on my PC. Everything works fine (did a lot of data send and receive) except that fpconnect with correct address (PC computer name) and port number still returns -1. Hence, this lines in the lNet lib (modified by me) if SetupSocket(APort, Address) then begin i:=fpConnect(FHandle, psockaddr(@FAddress), SizeOf(FAddress)); if i>=0 then FConnecting := True; Result := FConnecting; end; will always return false for the Connect function. The original code in lNet was if SetupSocket(APort, Address) then begin pConnect(FHandle, psockaddr(@FAddress), SizeOf(FAddress)); FConnecting := True; Result := FConnecting; end; which always returned TRUE, even when fpconnect fails; Any idea as to what I may check (beside the return code of fpconnect which does not work) to see if the conneccion actually took place? Thanks more information linux? windows? blocking or nonblocking sockets?

Reply by email

Martin
to epergola: Sorry, you are right. I am using non blocking sockets (lNet library), no visual package,…
epergola wrote 10 lines
Sorry, you are right. I am using non blocking sockets (lNet library), no visual package, on the wince-arm side, attempting to communicate with a non blocking (Delphi) socket on my PC. Everything works fine (did a lot of data send and receive) except that fpconnect with correct address (PC computer name) and port number still returns -1.

....

Show quoted text 6 lines
which always returned TRUE, even when fpconnect fails; Any idea as to what I may check (beside the return code of fpconnect which does not work) to see if the conneccion actually took place? Thanks

that would defeat the idea of a none-blocking connection.

none-blocking does not only relate to reading/writing data, but also to making the connection, which also could take several seconds and much longer.

A none blocking connection will return true in the connect event, if all local requirements where met. If you want to wait for the connection to take place (including the full timeout, if it fails) you should use a blocking socket for that.

Martin

Reply by email