• 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
Socket and big data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Socket and big data


  • Subject: Socket and big data
  • From: Peter Molnár <email@hidden>
  • Date: Mon, 21 Feb 2005 03:07:46 +0100

Ahoj,

I'm trying to make a simple communication between server and client. I want to make following: the client connect to the server, send a command, server receive it, process a received command and return processed command reply to the client.
I have a problem to receive any data bigger like an socket buffer(?) size(32kB).
On the server I send a reply with:

OSStatus err = CFSocketSendData(s, NULL, (CFDataRef)commandData, 0.0);

where the commandData are succesfully created.

On the client side I'm using for connecting to server:

- (OSStatus) connectToServer{
CFSocketContext context = {0, fs, NULL, NULL, NULL}; // fs is pointer to my object (self)
socket = CFSocketCreate(
kCFAllocatorDefault,
PF_INET,
SOCK_STREAM,
IPPROTO_TCP,
kCFSocketDataCallBack,
receive,
&context);


struct sockaddr_in addr;
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = inet_addr([ server cString ]);
addr.sin_port = port;

CFDataRef addressData = CFDataCreate( kCFAllocatorDefault, (UInt8 *)&addr, sizeof( struct sockaddr_in ) );

CFTimeInterval interval = 0;
err = CFSocketConnectToAddress(
socket,
addressData,
interval);


if( err == 0 )
{
CFRunLoopRef refRunLoop = [[ NSRunLoop currentRunLoop ] getCFRunLoop ];
CFRunLoopSourceRef sourceRunLoop = CFSocketCreateRunLoopSource(
kCFAllocatorDefault,
socket,
0);
CFRunLoopAddSource(
refRunLoop,
sourceRunLoop,
kCFRunLoopCommonModes);
return 0;
}
return err;
}

and for a receive:

void receive( CFSocketRef s, CFSocketCallBackType callbackType, CFDataRef address, const void *data, void *info )
{
NSDictionary *userInfo = [ NSMutableDictionary dictionaryWithObject:command forKey:@"Command" ];
NSNotification *aNotification = [ NSNotification notificationWithName:@"CommandReceived" object:(FolderSync *)info userInfo:userInfo ];
[[ NSNotificationCenter defaultCenter ] postNotification:aNotification ];
}

The problem is that receive() function receive just a 32kB and the next datas are received in the next loop. I'm don't know how to receive a full
data(can be 120MB) in a one notification(callback). I'm thought that const void *data should store a pointer with the full data replied.

Please, help me. Should I use kCFSocketReadCallBack(and how?) instead of kCFSockedDataCallback? How can I determine(on the client side) that data was fully received(not just a 32kB part)?
Mac is great but this make me crazy. Thanks a lot.

Peter Molnar
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Socket and big data
      • From: Santino <email@hidden>
  • Prev by Date: RE: How to specify FTP URL to fetch any file
  • Next by Date: Re: Socket and big data
  • Previous by thread: OT: where to find info on connecting to a wireless network by means of certificates
  • Next by thread: Re: Socket and big data
  • Index(es):
    • Date
    • Thread