• 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
AsyncSocket. Troubles with MTMessageBroker didReceiveData
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AsyncSocket. Troubles with MTMessageBroker didReceiveData


  • Subject: AsyncSocket. Troubles with MTMessageBroker didReceiveData
  • From: Carlo Gulliani <email@hidden>
  • Date: Mon, 6 Jul 2009 14:18:35 -0700 (PDT)

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@hidden)

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:

This email sent to email@hidden

  • Prev by Date: Re: Problem with NSDecimalNumber truncating zeros
  • Next by Date: Re: NSApplication and UIApplication
  • Previous by thread: Re: Problem with NSDecimalNumber truncating zeros
  • Next by thread: Re: AsyncSocket. Troubles with MTMessageBroker didReceiveData
  • Index(es):
    • Date
    • Thread