kornalius
10-11-2006, 06:06 PM
We have worked on an easy to use library to connect to Windows Sockets and Bluetooth devices.</p>
This new library will be available in 1.1 due next month.</p>
Here are the functions we have so far:</p><pre>proc SW_UrlInit
proc SW_UrlShut
func SW_UrlOpen(address$)
proc SW_UrlClose(hUrl$)
func SW_UrlCanConnect(hUrl$)
func SW_UrlContentType(hUrl$)
func SW_UrlReceiveFile(hUrl$)
proc SW_UrlSendFile(hUrl$, data$)</pre><pre>#define _INET AF_INET
#define _BT AF_BTH</pre><pre>func SW_Socket(typ$)
proc SW_CloseSocket(socket$)
func SW_GetHostAddr(address$)
proc SW_Listen(socket$, typ$, port$)
func SW_Connect(socket$, typ$, address$, port$)
func SW_Accept(socket$)
func SW_BufferSize(socket$)
func SW_Receive(socket$, async$)
proc SW_Send(socket$, data$)</pre>
To connect to the internet using Client/Server style here is a simple client program:</p><pre>#include "SWSock"</pre><pre>sock$ = SW_Socket(_INET);
if (SW_Connect(sock$, "myname.no-ip.com", 2342))
* Sw_Send(sock$, mydata$);
* Sw_CloseSocket(sock$);
end;</pre>
A simple server would be:</p><pre>#include "SWSock"</pre><pre>sock$ = SW_Socket(_INET);
if (SW_Listen(sock$, _INET, 2342))
* while (not finished$)
*** newsock$ = SW_Accept(sock$);
*** if (newsock$ != 0)
***** ShowMessage("New connection made");
***** Sw_CloseSocket(newsock$);
*** end;
* end;
* SW_CloseSocket(sock$);
end;</pre>
This library will evolve more in the future, if you have any comments or want to contribute, please use this thread.</p>
This new library will be available in 1.1 due next month.</p>
Here are the functions we have so far:</p><pre>proc SW_UrlInit
proc SW_UrlShut
func SW_UrlOpen(address$)
proc SW_UrlClose(hUrl$)
func SW_UrlCanConnect(hUrl$)
func SW_UrlContentType(hUrl$)
func SW_UrlReceiveFile(hUrl$)
proc SW_UrlSendFile(hUrl$, data$)</pre><pre>#define _INET AF_INET
#define _BT AF_BTH</pre><pre>func SW_Socket(typ$)
proc SW_CloseSocket(socket$)
func SW_GetHostAddr(address$)
proc SW_Listen(socket$, typ$, port$)
func SW_Connect(socket$, typ$, address$, port$)
func SW_Accept(socket$)
func SW_BufferSize(socket$)
func SW_Receive(socket$, async$)
proc SW_Send(socket$, data$)</pre>
To connect to the internet using Client/Server style here is a simple client program:</p><pre>#include "SWSock"</pre><pre>sock$ = SW_Socket(_INET);
if (SW_Connect(sock$, "myname.no-ip.com", 2342))
* Sw_Send(sock$, mydata$);
* Sw_CloseSocket(sock$);
end;</pre>
A simple server would be:</p><pre>#include "SWSock"</pre><pre>sock$ = SW_Socket(_INET);
if (SW_Listen(sock$, _INET, 2342))
* while (not finished$)
*** newsock$ = SW_Accept(sock$);
*** if (newsock$ != 0)
***** ShowMessage("New connection made");
***** Sw_CloseSocket(newsock$);
*** end;
* end;
* SW_CloseSocket(sock$);
end;</pre>
This library will evolve more in the future, if you have any comments or want to contribute, please use this thread.</p>