2013-01-07 76 views
0

我嘗試發送INVITE到SIP服務器:GCDAsyncSocket和發送SIP包

 GCDAsyncSocket *outgoingCallSocket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:socketOutgoingCallQueue]; 

     BOOL result = [outgoingCallSocket connectToHost:currentSoftswitch.ip onPort:5060 error:&error]; 

- (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag 

然後,插座連接時:

- (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(uint16_t)port; 
{ 
    NSLog(@"Connected socket to %@:%hu", host, port); 
    [sock writeData:finalData withTimeout:-1 tag:OUTGOING_CALL]; 
    NSLog(@"\n===================SEND START TO currentSoftswitch.ip->%@:5060 =================\n%@\n===================SEND FINISH=================\n",host,[[NSString alloc] initWithData:finalData encoding:NSUTF8StringEncoding]); 

這裏是結果:

> ===================SEND START TO currentSoftswitch.ip->195.26.84.147:5060 ================= INVITE 
> sip:[email protected];transport=tcp;lr SIP/2.0 Via: 
> SIP/2.0/TCP 195.26.84.147:5060;rport;lr SIP/2.0 Max-Forwards: 70 From: 
> "[email protected]" 
> <sip:[email protected]>;tag=Ztr3.0MabqPlVkNJHHVdvAdeNGUXsz8E To: 
> sip:[email protected] Contact: "[email protected]" 
> <sip:[email protected]:5060;transport=TCP;ob> Call-ID: 
> zu.MBTPcv87dylX2i-BsA.b551Kyflic CSeq: 25575 INVITE Route: 
> <sip:195.26.84.147;transport=tcp;lr> Route: <sip:195.26.84.147;lr> 
> Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, SUBSCRIBE, NOTIFY, 
> REFER, MESSAGE, OPTIONS Supported: replaces, 100rel, timer, norefersub 
> Session-Expires: 1800 Min-SE: 90 User-Agent: CallsFreeCalls 
> SSContent-Type: application/sdp Content-Length: 480 
> 
> v=0 o=- 3566574154 3566574154 IN IP4 46.211.183.202 s=pjmedia c=IN IP4 
> 46.211.183.202 b=AS:84 t=0 0 a=X-nat:6 m=audio 40000 RTP/AVP 104 18 108 3 8 0 96 c=IN IP4 46.211.183.202 b=TIAS:64000 a=rtcp:40001 IN IP4 
> 46.211.183.204 a=sendrecv a=rtpmap:104 SILK/8000 a=fmtp:104 useinbandfec=0 a=rtpmap:18 G729/8000 a=rtpmap:108 iLBC/8000 a=fmtp:108 
> mode=30 a=rtpmap:3 GSM/8000 a=rtpmap:8 PCMA/8000 a=rtpmap:0 PCMU/8000 
> a=rtpmap:96 telephone-event/8000 
> 
> ===================SEND FINISH================= 

但是當我檢查whireshark時,數據包不會像SIP一樣檢測到。我錯了?

enter image description here

+0

爲什麼你使用2個socket對象?有特別的原因嗎? –

回答

0

SIMPLE答案 - 錯誤的內容,lenght!