32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
32
33
34
35
36
37
38
39
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
* Connect the OFTCPSocket to the specified destination.
*
* \param host The host to connect to
* \param port The port of the host to connect to
*/
- connectTo: (const char*)host
onPort: (uint16_t)port;
/**
* Receive data from the socket into a buffer.
*
* \param buf The buffer into which the data is read
* \param size The size of the data that should be read.
* The buffer MUST be at least size big!
* \return The number of bytes read
*/
- (size_t)readNBytes: (size_t)size
intoBuffer: (uint8_t*)buf;
/**
* Receive data from the socket into a new buffer.
*
* \param size The size of the data that should be read
* \return A new buffer with the data read.
* It is part of the memory pool of the OFFile.
*/
- (uint8_t*)readNBytes: (size_t)size;
/**
* Sends data from a buffer.
*
* \param buf The buffer from which the data is written to the file
* \param size The size of the data that should be written
* \return The number of bytes written
*/
- (size_t)writeNBytes: (size_t)size
fromBuffer: (const uint8_t*)buf;
/**
* Sends a C string, without the trailing zero.
*
* \param str The C string from which the data is sent
* \return The number of bytes written
*/
- (size_t)writeCString: (const char*)str;
/**
* Closes the OFTCPSocket.
*/
- close;
@end
|