Code archives/Networking/Simple connections
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
No worrying about opening and closing sockets. Just simple functions to open a stream to a remote location. Only good for the simplest setups, of course. | |||||
SuperStrict Import BRL.SocketStream Function AcceptSocketStream:TSocketStream(port:Int, timeout:Int) Local conn:TSocket = CreateTCPSocket() If Not conn.Bind(port) conn.Close Return Null End If conn.Listen(0) Local s:TSocket = conn.Accept(timeout) conn.Close If Not s Return Null Return CreateSocketStream(s, True) End Function Function RequestSocketStream:TSocketStream(ip:Int, port:Int) Local s:TSocket = CreateTCPSocket() If Not s.Connect(ip, port) s.Close Return Null End If Return CreateSocketStream(s, True) End Function |
Comments
None.
Code Archives Forum