我尝试将邀请发送到 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:380442399740@91.224.223.42;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:
> "alex@ixc.ua"
> <sip:897542@91.224.223.42>;tag=Ztr3.0MabqPlVkNJHHVdvAdeNGUXsz8E To:
> sip:380442399740@195.26.84.147 Contact: "alex@ixc.ua"
> <sip:897542@10.129.244.143: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 那样检测到数据包。我哪里错了?