Sign in Join

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

Mailing lists / fpc-pascal / 2003-08

win32 server socket problem

6 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Balázs Csaba

I found a problem at night, and ia cannot solve it in 5 hours.

I wrote the simple server side on linux (socket, bind, listen.... accept). I connect to this server with a simple Delphi5 client on port 2001 (i tried any other). The "while (not eof(sin))" stops and waits for the forst packet, and so on.
But on windows (with win32 compiler) the same program can read garbage data from sin (text type) and the data is infinity, so i cannot be the end of data.
What is the difference betwwen win32 and linux socket units? What can I do to compile the program perfectly on win32?
// I tried to use file against text sin, sout, and read it by blockread, but it was the same.

Thanx! Best regards
#Tsch : Balázs Csaba

Reply by email

Michael Van Canneyt
to Balázs Csaba
Show quoted text 11 lines
I found a problem at night, and ia cannot solve it in 5 hours. I wrote the simple server side on linux (socket, bind, listen.... accept). I connect to this server with a simple Delphi5 client on port 2001 (i tried any other). The "while (not eof(sin))" stops and waits for the forst packet, and so on. But on windows (with win32 compiler) the same program can read garbage data from sin (text type) and the data is infinity, so i cannot be the end of data. What is the difference betwwen win32 and linux socket units? What can I do to compile the program perfectly on win32?

The problem is not in the sockets unit, I think, but in the handling of text files on Win32. I don't know whether there is a simple solution for this.

Michael.

Reply by email

Balázs Csaba
to Michael Van Canneyt

Yes, maybe it is a text file problem, but I cannot solve it. Did somebody make same program on win32?
Could I try it with recv(), send()? In this case how can i detect the end of communication?

#Tsch : Balázs Csaba

Show quoted text 21 lines
> I found a problem at night, and ia cannot solve it in 5 hours. > > I wrote the simple server side on linux (socket, bind, listen.... > accept). I connect to this server with a simple Delphi5 client on port > 2001 (i tried any other). The "while (not eof(sin))" stops and waits > for the forst packet, and so on. But on windows (with win32 compiler) > the same program can read garbage data from sin (text type) and the > data is infinity, so i cannot be the end of data. > What is the difference betwwen win32 and linux socket units? What can I do > to compile the program perfectly on win32? The problem is not in the sockets unit, I think, but in the handling of text files on Win32. I don't know whether there is a simple solution for this. Michael.

Reply by email

Michael Van Canneyt
to Balázs Csaba
Yes, maybe it is a text file problem, but I cannot solve it. Did somebody make same program on win32? Could I try it with recv(), send()? In this case how can i detect the end of communication?

Normally, with select() you can determine whether there is data. with recv() and the MSG_PEEK flag, you can have a peek. This should return 0 if there is no data or the connection was closed.

Michael.

Reply by email

Balázs Csaba
to Michael Van Canneyt

Ok, fine!

So i can replace procedures that can use textfiles to use recv/send and select(). I am trying now... GOOD!

Thx!

Is select() existing in win32 platform?

#Tsch : Balázs Csaba

Show quoted text 20 lines
On Fri, 15 Aug 2003, [iso-8859-2] Balázs Csaba wrote: > Yes, maybe it is a text file problem, but I cannot solve it. Did > somebody make same program on win32? Could I try it with recv(), > send()? In this case how can i detect the end of communication? Normally, with select() you can determine whether there is data. with recv() and the MSG_PEEK flag, you can have a peek. This should return 0 if there is no data or the connection was closed. Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/f> pc-pascal

Reply by email

Michael Van Canneyt
to Balázs Csaba
Show quoted text 8 lines
Ok, fine! So i can replace procedures that can use textfiles to use recv/send and select(). I am trying now... GOOD! Thx! Is select() existing in win32 platform?

It should exist in the winsock unit, I think. It's definitely in winsock.dll

Michael.

Reply by email