• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CFSocket Callback
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >CFSocket Callback (From: "Edward Fink" <email@hidden>)

  • Prev by Date: CFSocket Callback
  • Next by Date: Re: OS X Socket Performance
  • Previous by thread: CFSocket Callback
  • Next by thread: Re: CFSocket Callback
  • Index(es):
    • Date
    • Thread