I'm trying to send bytes with help AsyncSocket and MTMessageBroker
At first, i have connection with static server, which return to me ip and port
of dynamic server. i made so
...
[socket connectToHost:@"here_is_ip" onPort:here_is_port error:&error]; // it's
correct. I did receive new ip and port. so after it i close connection and
after parsed i have connection to new address
[socket disconnect];
...
[socket connectToHost:@"here_is_new_ip" onPort:here_is_new_port error:&error];
// ok.good
so, my method(void)onSocket:(AsyncSocket *)sock didConnectToHost:(NSString
*)host port:(UInt16)port
in the second time i start to make packet with necessary bytes. here is correct
too, after it i made NSMutableData with my bytes
...
char bytes[24] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
NSMutableData* data = [NSMutableData dataWithBytes:(unsigned char*)
&packet length:20];
[data appendBytes:(unsigned char*)&bytes length:sizeof(bytes)];
//next i trying to send it and receive answer
MTMessage *newMessage = [[[MTMessage alloc] init] autorelease];
newMessage.tag = 0;
newMessage.dataContent = data;
[self.messageBroker sendMessage:newMessage];
// method told me, data was successfully sent
#pragma mark MTMessageBroker Delegate Methods
-(void)messageBroker:(MTMessageBroker *)server didSendMessage:
(MTMessage *)message
{
NSLog(@"%d bytes. data is %@", [message.dataContent length],
message.dataContent); // 44 bytes. data is <EFBEADDE 14000100 00000000
01100000 00000000 00000000 00000000 00000000 00000000 00000000
00000000> it's correct
}
// but i dont received result. I should receive like this EFBEADDE
14000100 00000000 01100000 00000000 00000000 00000000 00000000
00000000 02c01100 00430c00
-(void)messageBroker:(MTMessageBroker *)server didReceiveMessage:
(MTMessage *)message
{
[self display:@"Message broker"]; // it did not shows
if ( message.tag == 0 )
{
NSString *str = [[[NSString alloc] initWithData:message.dataContent
encoding:NSUTF8StringEncoding] autorelease];
}
}
where is mistake? i've been trying to send it via php (i wrote mini class and
sent packet, the packet has been the same like in obj-c, absolutely. there it
works). So, i cannot send already the 3rd day it
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]