Recent

Author Topic: Problem with threads and sockets in Suse Enterprise 11 SP2  (Read 8020 times)

Thaddy

  • Hero Member
  • *****
  • Posts: 14382
  • Sensorship about opinions does not belong here.
Re: Problem with threads and sockets in Suse Enterprise 11 SP2
« Reply #15 on: January 20, 2017, 06:35:09 pm »
It is not about the datatype. You were just right in assuming that sockets are thread-local by definition. On any platform that supports threads.
The datatype can also be homologous since it is all POSIX, Berkely sockets, even on Windows. If the structures differ, the underlying data doesn't!
Otherwise e.g. the internet would fall apart... :'( :'( :'(
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

Fungus

  • Sr. Member
  • ****
  • Posts: 353
Re: Problem with threads and sockets in Suse Enterprise 11 SP2
« Reply #16 on: January 20, 2017, 07:26:29 pm »
Hehe.. Easy now.. Of cource the socket layer and protocols is identical, anything else would be a mad assumption. But the way sockets are (programmatically) handled on different systems does vary. Setting a sockets read timeout is done with:

Code: Pascal  [Select][+][-]
  1. fpSetSockOpt(ASocketHandle, SOL_SOCKET, SO_RCVTIMEO, @T, SizeOf(T));

Where T is of type DWORD (milliseconds) on Windows and of type TIMEVAL (record/struct with seconds and microseconds - both qwords/int64) on Linux. Since the two data types have different sizes they are not cross platform compatible. Low level socket functions may have the same names, but the usage differs (ever so slightly) :)
« Last Edit: January 20, 2017, 08:25:29 pm by Fungus »

Thaddy

  • Hero Member
  • *****
  • Posts: 14382
  • Sensorship about opinions does not belong here.
Re: Problem with threads and sockets in Suse Enterprise 11 SP2
« Reply #17 on: January 20, 2017, 08:54:42 pm »
Did you check the values? they are interchangeable and implementation detail. You can replace those routines and their structures and it will still work.
Just a matter of how the programmer felt that day.
You can also hardcast them both ways and it will still work. That's called POSIX compliant. And the UC Berkeley sockets implementation is part of POSIX since the 80's.

You should really brush up your theory: Just because something looks different, it doesn't mean it is different... <grumpy: This is really silly.  >:D >

The only thing of influence that CAN be different is the calling convention, but, again, that is implementation detail.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

Fungus

  • Sr. Member
  • ****
  • Posts: 353
Re: Problem with threads and sockets in Suse Enterprise 11 SP2
« Reply #18 on: January 20, 2017, 09:10:16 pm »
What values are interchangeable? The identical calls to (fp)setsockopt Linux/Windows differs slightly in the data passed, you cannot use a DWORD as timeout on Linux and you cannot use a TIMEVAL as timeout on Windows - setsockopt will fail in both cases. So it is in fact different, yeah??

Thaddy

  • Hero Member
  • *****
  • Posts: 14382
  • Sensorship about opinions does not belong here.
Re: Problem with threads and sockets in Suse Enterprise 11 SP2
« Reply #19 on: January 20, 2017, 09:26:17 pm »
Oh, come on. Check the data sizes.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

Fungus

  • Sr. Member
  • ****
  • Posts: 353
Re: Problem with threads and sockets in Suse Enterprise 11 SP2
« Reply #20 on: January 20, 2017, 09:34:19 pm »
Oh, come on. Check the data sizes.

SizeOf(DWORD) = 4 <> SizeOf(TIMEVAL) = 16. Please climb down your throne and gain some real world knowledge..

 

TinyPortal © 2005-2018