Re: CFSocket Callback
Re: CFSocket Callback
- Subject: Re: CFSocket Callback
- From: Jens Bauer <email@hidden>
- Date: Mon, 9 Sep 2002 19:03:24 +0200
Hi Edward,
On Mon, 9 Sep, 2002, Edward Fink <email@hidden> wrote:
>
Using something similar to the following I can printf the data, but I
>
haven't figured out how
>
to get it into a regular string for manipulation.
>
>
Any ideas?
>
>
void whatToDo(CFSocketRef s, CFSocketCallBackType type, CFDataRef
>
address, const void *data, void *info)
>
{
>
printf ("%.*s\n\n", (int)CFDataGetLength(data),
>
CFDataGetBytePtr(data));
>
>
}
I don't know the correct solution, but you could use...
char *str;
long l;
str = (char *) malloc(10 + (int) CFDataGetLength(data) + 1);
if(str)
{
l = sprintf(str, "%.*s\n\n", (int) CFDataGetLength(data),
CFDataGetBytePtr(data));
...
free(str);
}
(yes, the +10 is a bit sloppy, but this is just an example. The +1 is for
the zero-termination)
l is the length of the final string, so you don't have to strlen it.
Love,
Jens
--
Jens Bauer, Faster Software.
-Let's make the World better, shall we ?
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.