1

i have wierd problem to send informations and the data to TCP server. My code was made with C and Objective-C. I send the information and after i send my data in same connection.

TCPClient *tcp = [[TCPClient alloc] init];
TCPResponse c = [tcp connectWithHost:@"127.0.0.1" onPort:@"2506" withTimeout:30];
TCPResponse sendInfo = [tcp sendString:msg];
TCPResponse send = [tcp sendData: data];

The sendInfo arrives fine, but the other...

const void *dataBytes = [data bytes];
unsigned long length = [data length];
//NSLog(@"[####]\n %s [%ld][%ld]", dataBytes, sizeof(dataBytes), [data length]);

ssize_t bytes_sent = send(_sockfd, dataBytes, length, 0);
if (bytes_sent < length) {
    /* Se não enviar: retorna erro */
    return [TCPClient setupError:errno withDefault: TCPResponseErrorToSend];
}

If the commented line is commented i have error in the server, if not the data arrives fine. If I put sleep instead the commented line the data arrives fine.

My server was implemented in Java.

Thank you.

2
  • What is the value of errno after send() fails? You'd need to #include <errno.h> to get access to errno. Which 'commented line' do you mean, the one with NSLog()??? Jun 13, 2013 at 13:29
  • @meaning-matters , this code is C and Objective-C hybrid, the NSLog is like printf with ease. I don't have errors to send, my error is in server, my file arrives broken. Jun 14, 2013 at 19:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.