| 1 |
EasyNet |
| 2 |
======= |
| 3 |
|
| 4 |
Simple TCP networking wrapping OpenTransport. |
| 5 |
|
| 6 |
Files |
| 7 |
----- |
| 8 |
EasyNet.h public API |
| 9 |
EasyNet.c implementation |
| 10 |
HelloWorld.c example finger client |
| 11 |
|
| 12 |
Building |
| 13 |
-------- |
| 14 |
Tested with CodeWarrior Pro 6 under Mac OS 9.2 with a PPC machine. |
| 15 |
|
| 16 |
1. Create new project |
| 17 |
2. Add EasyNet.c and HelloWorld.c to the project |
| 18 |
3. Add from Mac OS Support:Universal:Libraries: |
| 19 |
PPCLibraries:OpenTransportAppPPC.o |
| 20 |
PPCLibraries:OpenTptInetPPC.o |
| 21 |
StubLibraries:OpenTransportLib |
| 22 |
StubLibraries:OpenTptInternetLib |
| 23 |
4. Build and run |
| 24 |
|
| 25 |
Usage |
| 26 |
----- |
| 27 |
EasyNet_Init |
| 28 |
EasyNet_Shutdown |
| 29 |
Call once at app start / quit. |
| 30 |
|
| 31 |
EasyNet_Connect(host, port, timeoutSecs, &conn) |
| 32 |
Resolves host, opens TCP connection. Returns noErr or error. |
| 33 |
|
| 34 |
EasyNet_Send(conn, data, length) |
| 35 |
EasyNet_SendString(conn, s) |
| 36 |
Sends all bytes. Returns noErr or error. |
| 37 |
|
| 38 |
EasyNet_Receive(conn, buf, size) |
| 39 |
Returns > 0 bytes received, 0 server closed, < 0 on error. |
| 40 |
Does not add terminating '\0'. |
| 41 |
|
| 42 |
EasyNet_Close(conn) |
| 43 |
Closes the connection and frees it. |
| 44 |
|
| 45 |
kEasyNetCRLF |
| 46 |
Network line ending, use it instead of "\r\n". |