Browse Source

+ merged missing sendto/rcvfrom functions

michael 23 years ago
parent
commit
26db724c09
4 changed files with 68 additions and 5 deletions
  1. 11 0
      rtl/freebsd/unixsock.inc
  2. 14 1
      rtl/inc/socketsh.inc
  3. 12 3
      rtl/linux/unixsock.inc
  4. 31 1
      rtl/win32/sockets.pp

+ 11 - 0
rtl/freebsd/unixsock.inc

@@ -12,11 +12,22 @@ begin
   Send:=do_syscall(syscall_nr_sendto,Sock,Longint(@Buf),BufLen,Flags,0,0);
 end;
 
+Function SendTo(Sock:Longint;Const Buf;BufLen,Flags:Longint;Var Addr; AddrLen : Longint):Longint;
+begin
+  Sendto:=SocketCall(syscall_nr_Sendto,Sock,Longint(@Buf),BufLen,Flags,Longint(@Addr),AddrLen);
+end;
+
 Function Recv(Sock:Longint;Var Buf;BufLen,Flags:Longint):Longint;
 begin
   Recv:=do_syscall(syscall_nr_Recvfrom,Sock,Longint(@Buf),BufLen,Flags,0,0);
 end;
 
+Function RecvFrom(Sock : Longint; Var Buf; Buflen,Flags : Longint; Var Addr ; AddrLen : Integer) : longint;
+
+begin
+  RecvFrom:=do_syscall(syscall_nr_Recvfrom,Sock,Longint(@buf),buflen,flags,Longint(@Addr),AddrLen);
+end;
+
 Function Bind(Sock:Longint;Const Addr;AddrLen:Longint):Boolean;
 begin
   Bind:=(do_syscall(syscall_nr_Bind,Sock,Longint(@Addr),AddrLen)=0);

+ 14 - 1
rtl/inc/socketsh.inc

@@ -133,7 +133,9 @@ Var
 {Basic Socket Functions}
 Function Socket(Domain,SocketType,Protocol:Longint):Longint;
 Function Send(Sock:Longint;Const Buf;BufLen,Flags:Longint):Longint;
+Function SendTo(Sock:Longint;Const Buf;BufLen,Flags:Longint;Var Addr; AddrLen : Longint):Longint;
 Function Recv(Sock:Longint;Var Buf;BufLen,Flags:Longint):Longint;
+Function RecvFrom(Sock : Longint; Var Buf; Buflen,Flags : Longint; Var Addr; AddrLen : Integer) : longint;
 Function Bind(Sock:Longint;Const Addr;AddrLen:Longint):Boolean;
 Function Listen (Sock,MaxConnect:Longint):Boolean;
 Function Accept(Sock:Longint;Var Addr;Var Addrlen:Longint):Longint;
@@ -159,10 +161,21 @@ Function Connect(Sock:longint;const addr:TInetSockAddr;var SockIn,SockOut:file):
 
 {
   $Log$
-  Revision 1.6  2001-06-06 21:58:24  peter
+  Revision 1.7  2002-02-04 21:29:34  michael
+  + merged missing sendto/rcvfrom functions
+
+  Revision 1.6  2001/06/06 21:58:24  peter
     * Win32 fixes for Makefile so it doesn't require sh.exe
 
   Revision 1.5  2001/06/04 11:43:51  peter
+
+  Revision 1.1.2.4  2002/02/04 21:25:28  michael
+    + Added missing sendto/rcvfrom functions
+
+  Revision 1.1.2.3  2001/06/06 22:00:39  peter
+    * Win32 fixes
+
+  Revision 1.1.2.2  2001/06/04 11:43:18  peter
     * Formal const to var fixes
     * Hexstr(int64) added
 

+ 12 - 3
rtl/linux/unixsock.inc

@@ -78,21 +78,27 @@ begin
   Socket:=SocketCall(Socket_Sys_Socket,Domain,SocketType,ProtoCol);
 end;
 
-
-
 Function Send(Sock:Longint;Const Buf;BufLen,Flags:Longint):Longint;
 begin
   Send:=SocketCall(Socket_Sys_Send,Sock,Longint(@Buf),BufLen,Flags,0,0);
 end;
 
 
+Function SendTo(Sock:Longint;Const Buf;BufLen,Flags:Longint;Var Addr; AddrLen : Longint):Longint;
+begin
+  Sendto:=SocketCall(Socket_Sys_SendTo,Sock,Longint(@Buf),BufLen,Flags,Longint(@Addr),AddrLen);
+end;
 
 Function Recv(Sock:Longint;Var Buf;BufLen,Flags:Longint):Longint;
 begin
   Recv:=SocketCall(Socket_Sys_Recv,Sock,Longint(@Buf),BufLen,Flags,0,0);
 end;
 
+Function RecvFrom(Sock : Longint; Var Buf; Buflen,Flags : Longint; Var Addr ; AddrLen : Integer) : longint;
 
+begin
+  RecvFrom:=SocketCall(Socket_Sys_Recv,Sock,Longint(@buf),buflen,flags,Longint(@Addr),AddrLen);
+end;
 
 Function Bind(Sock:Longint;Const Addr;AddrLen:Longint):Boolean;
 begin
@@ -261,7 +267,10 @@ end;
 
 {
   $Log$
-  Revision 1.4  2001-06-10 08:51:44  peter
+  Revision 1.5  2002-02-04 21:29:34  michael
+  + merged missing sendto/rcvfrom functions
+
+  Revision 1.4  2001/06/10 08:51:44  peter
     * forgotten file for the const to var fixes
 
   Revision 1.3  2001/06/04 11:43:51  peter

+ 31 - 1
rtl/win32/sockets.pp

@@ -53,6 +53,16 @@ begin
     SocketError:=0;
 end;
 
+Function SendTo(Sock:Longint;Const Buf;BufLen,Flags:Longint;Var Addr; AddrLen : Longint):Longint;
+begin
+  // Dubious construct, this should be checked.
+  Send:=WinSock.SendTo(Sock,Buf,BufLen,Flags,Winsock.TSockAddr(Addr),AddrLen);
+  if Send<0 then
+    SocketError:=WSAGetLastError
+  else
+    SocketError:=0;
+end;
+
 Function Recv(Sock:Longint;Var Buf;BufLen,Flags:Longint):Longint;
 begin
   Recv:=WinSock.Recv(Sock,Buf,BufLen,Flags);
@@ -62,6 +72,17 @@ begin
     SocketError:=0;
 end;
 
+
+Function RecvFrom(Sock : Longint; Var Buf; Buflen,Flags : Longint; Var Addr; AddrLen : Integer) : longint;
+
+begin
+  Recv:=WinSock.RecvFrom(Sock,Buf,BufLen,Flags,Winsock.TSockAddr(Addr),AddrLen);
+  if Recv<0 then
+    SocketError:=WSAGetLastError
+  else
+    SocketError:=0;
+end;
+
 Function Bind(Sock:Longint;Const Addr;AddrLen:Longint):Boolean;
 
   var
@@ -224,9 +245,18 @@ finalization
 end.
 {
   $Log$
-  Revision 1.5  2001-06-06 21:58:24  peter
+  Revision 1.6  2002-02-04 21:29:34  michael
+  + merged missing sendto/rcvfrom functions
+
+  Revision 1.5  2001/06/06 21:58:24  peter
     * Win32 fixes for Makefile so it doesn't require sh.exe
 
+  Revision 1.1.2.4  2002/02/04 21:25:28  michael
+  + Added missing sendto/rcvfrom functions
+
+  Revision 1.1.2.3  2001/06/06 22:00:40  peter
+    * Win32 fixes
+
   Revision 1.4  2000/07/28 08:43:46  sg
   * Applied patch by Markus Kaemmerer: Fixes fdRead and fdWrite