WM_USER = 1024;\r
WM_TIMER = 275;\r
INFINITE = syncobjs.infinite;\r
+\r
function getwindowlongptr(ahwnd:hwnd;nindex:integer) : taddrint;\r
function setwindowlongptr(ahwnd:hwnd;nindex:integer;dwNewLong : taddrint) : taddrint;\r
function DefWindowProc(ahWnd:HWND; auMsg:Integer; awParam:WPARAM; alParam:LPARAM):Integer; stdcall;\r
{$i unixstuff.inc}\r
\r
type\r
+ \r
tmessageintransit = class\r
msg : tmsg;\r
next : tmessageintransit;\r
waiting : boolean;\r
lcorethread : boolean;\r
nexttimer : ttimeval;\r
- threadid : integer;\r
+ threadid : tthreadid;\r
end;\r
twindow=class\r
hwnd : hwnd;\r
\r
\r
//findthreaddata should only be called while holding the structurelock\r
-function findthreaddata(threadid : integer) : tthreaddata;\r
+function findthreaddata(threadid : tthreadid) : tthreaddata;\r
begin\r
- result := tthreaddata(findtree(@threaddata,inttostr(threadid)));\r
+ result := tthreaddata(findtree(@threaddata,inttostr(taddrint(threadid))));\r
if result = nil then begin\r
result := tthreaddata.create;\r
result.messageevent := teventobject.create(nil,false,false,inttostr(taddrint(result)));\r
result.nexttimer := tv_invalidtimebig;\r
result.threadid := threadid;\r
- addtree(@threaddata,inttostr(threadid),result);\r
+ addtree(@threaddata,inttostr(taddrint(threadid)),result);\r
end;\r
end;\r
\r
//writeln('freeing thread data object');\r
athreaddata.free;\r
//writeln('deleting thread data object from hashtable');\r
- deltree(@threaddata,inttostr(athreaddata.threadid));\r
+ deltree(@threaddata,inttostr(taddrint(athreaddata.threadid)));\r
//writeln('finished deleting thread data');\r
end else begin\r
//writeln('thread data is not unused');\r
//writeln('aboute to delete window from windows structure');\r
deltree(@windows,inttostr(ahwnd));\r
//writeln('deleted window from windows structure');\r
- windowthreaddata := tthreaddata(findtree(@threaddata,inttostr(window.threadid)));\r
+ windowthreaddata := tthreaddata(findtree(@threaddata,inttostr(taddrint(window.threadid))));\r
\r
if windowthreaddata <> nil then begin\r
//writeln('found thread data scanning for messages to clean up');\r
begin\r
result := getpeername(sock,addr,addrlen);\r
end;\r
- function system_getsocketname(Sock: LongInt;var Addr;var Addrlen: LongInt):LongInt;\r
- begin\r
- result := getsocketname(sock,addr,addrlen);\r
- end;\r
function system_listen(Sock: LongInt; MaxConnect: LongInt):Boolean;\r
begin\r
result := listen(sock,maxconnect);\r
\r
procedure tlsocket.listen;\r
var\r
- yes:longint;\r
+ yes,no:longint;\r
socktype:integer;\r
biniptemp:tbinip;\r
origaddr:string;\r
try\r
yes := $01010101; {Copied this from existing code. Value is empiric,\r
but works. (yes=true<>0) }\r
+ no := 0;\r
{$ifndef win32}\r
if SetSocketOptions(fdhandlein, SOL_SOCKET, SO_REUSEADDR,yes,sizeof(yes))=-1 then begin\r
raise ESocketException.create('unable to set socket options');\r
end;\r
+ if SetSocketOptions(fdhandlein, IPPROTO_IPV6,IPV6_V6ONLY,no,sizeof(no))=-1 then begin\r
+ raise ESocketException.create('unable to set socket options');\r
+ end;\r
{$endif}\r
localaddr := addr;\r
localport := port;\r
{$ifdef win32}\r
winsock.getsockname(self.fdhandlein,psockaddr(@addr)^,i);\r
{$else}\r
- system_getsocketname(self.fdhandlein,addr,i);\r
+ getsocketname(self.fdhandlein,addr,i);\r
{$endif}\r
binip := inaddrvtobinip(addr);\r
converttov4(binip);\r
winsock.getsockname(self.fdhandlein,psockaddrin(@addr)^,i);\r
\r
{$else}\r
- system_getsocketname(self.fdhandlein,addr,i);\r
+ getsocketname(self.fdhandlein,addr,i);\r
\r
{$endif}\r
result := inttostr(htons(addr.InAddr.port));\r