L
Lawrie
Hi,
I have checked the FAQ and can't find an answer to something that has
been bugging me for a while.......
I am using the socket.h write function in non blocking mode
char* message = "blah blah blah";
int bytes_sent
int message_length = strlen(message);
bytes_sent = write(socket_id, message, message_length);
If bytes_sent is greater than 0 then some of my message has been sent.
If bytes_sent < message_length then some of my message remains unsent
so I need resend the rest.
Here is my question:
I know that my char pointer is equivalent to the first element of a \0
terminated character array.
If I then set the pointer to point to the first unsent char in the
array can I then pass this as the remining unsent part of the string to
the write function (in effect a ponter to a substring containing the n
last chars in the original string)?
Example
char* message = "Mary had a little lamb";
write function returns 5 bytes sent.
Can I then call write again with *(message + 5) to send the remainder
of the string?
If not is there a better/safer method?
Many thanks
Lawrie
I have checked the FAQ and can't find an answer to something that has
been bugging me for a while.......
I am using the socket.h write function in non blocking mode
char* message = "blah blah blah";
int bytes_sent
int message_length = strlen(message);
bytes_sent = write(socket_id, message, message_length);
If bytes_sent is greater than 0 then some of my message has been sent.
If bytes_sent < message_length then some of my message remains unsent
so I need resend the rest.
Here is my question:
I know that my char pointer is equivalent to the first element of a \0
terminated character array.
If I then set the pointer to point to the first unsent char in the
array can I then pass this as the remining unsent part of the string to
the write function (in effect a ponter to a substring containing the n
last chars in the original string)?
Example
char* message = "Mary had a little lamb";
write function returns 5 bytes sent.
Can I then call write again with *(message + 5) to send the remainder
of the string?
If not is there a better/safer method?
Many thanks
Lawrie