Sign in Join

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

Mailing lists / fpc-pascal / 2002-12

SetSocketOptions() in Linux

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

Brad Campbell

G'day all,

This has been a problem for me for a couple of years and I have only just solved it. (It was not a high priority).

S is a Socket.
I wanted to
SetSocketOptions(S,SOL_SOCKET,SO_REUSEADDR,1,Sizeof(1));

I looked at heaps of C source, and they did it with an int variable. So I used

Var
	Temp : Integer;
Temp := 1;
SetSocketOptions(S,SOL_SOCKET,SO_REUSEADDR,Temp,Sizeof(Temp));

This never worked, but it turns out that

Const
	Temp = 1;
SetSocketOptions(S,SOL_SOCKET,SO_REUSEADDR,Temp,Sizeof(Temp));

Or

SetSocketOptions(S,SOL_SOCKET,SO_REUSEADDR,1,Sizeof(1));

Both work fine.
Why does the first one fail and both the second ones work. What am I missing.

I have solved the problem and I'm much happier for it, but I'd like to know what basic concept I'm not grasping.

Brad.... /"\ Save the Forests \ / ASCII RIBBON CAMPAIGN Burn a Greenie. X AGAINST HTML MAIL / \

Reply by email

Bob Martin
to Brad Campbell

Hi Brad,
yes, this was a known bug for a long time, but a few months ago I read in a newsgroup that it was fixed in the latest version of RXSOCK.DLL so I changed the 5 programs where I used it to uncomment the line and sure enough it now worked.
My rxsock is
"rxsock .dll 73308 A 17-09-01 11:01:46 C:\TCPIP\dll" and I think it came with MCP2.
I use both
rc = SockSetSockOpt(s0,'Sol_Socket','So_ReuseAddr','ON') and
rc = SockSetSockOpt(s,'SOL_SOCKET','SO_REUSEADDR',1) and both seem to work !

Bob

Brad Campbell wrote 36 lines
G'day all, This has been a problem for me for a couple of years and I have only just solved it. (It was not a high priority). S is a Socket. I wanted to SetSocketOptions(S,SOL_SOCKET,SO_REUSEADDR,1,Sizeof(1)); I looked at heaps of C source, and they did it with an int variable. So I used Var Temp : Integer; Temp := 1; SetSocketOptions(S,SOL_SOCKET,SO_REUSEADDR,Temp,Sizeof(Temp)); This never worked, but it turns out that Const Temp = 1; SetSocketOptions(S,SOL_SOCKET,SO_REUSEADDR,Temp,Sizeof(Temp)); Or SetSocketOptions(S,SOL_SOCKET,SO_REUSEADDR,1,Sizeof(1)); Both work fine. Why does the first one fail and both the second ones work. What am I missing. I have solved the problem and I'm much happier for it, but I'd like to know what basic concept I'm not grasping.

Reply by email

Karagiannidis Savvas
to Brad Campbell: This has been a problem for me for a couple of years and I have only just solved it. (It…
Show quoted text 43 lines
G'day all, This has been a problem for me for a couple of years and I have only just solved it. (It was not a high priority). S is a Socket. I wanted to SetSocketOptions(S,SOL_SOCKET,SO_REUSEADDR,1,Sizeof(1)); I looked at heaps of C source, and they did it with an int variable. So I used Var Temp : Integer; Temp := 1; SetSocketOptions(S,SOL_SOCKET,SO_REUSEADDR,Temp,Sizeof(Temp)); This never worked, but it turns out that Const Temp = 1; SetSocketOptions(S,SOL_SOCKET,SO_REUSEADDR,Temp,Sizeof(Temp)); Or SetSocketOptions(S,SOL_SOCKET,SO_REUSEADDR,1,Sizeof(1)); Both work fine. Why does the first one fail and both the second ones work. What am I missing. I have solved the problem and I'm much happier for it, but I'd like to know what basic concept I'm not grasping. -- Brad.... /"\ Save the Forests \ / ASCII RIBBON CAMPAIGN Burn a Greenie. X AGAINST HTML MAIL / \

I have used SetSocketOptions the first way (using an integer variable) and it works fine for me...

Savvas

Reply by email