What i'm trying to do is implement a SIP client which listens for SIP messages.Ok so i have run the SIP client on a server 192.168.0.246 and the SIP server is running on 192.168.2.40.Now have a look at the below screen shot.
Its a trace file of the server running the client code on 192.168.0.246. As u can see the server receives messages from 192.168.2.40 using SIP/SDP protocol but when the client program running on 192.168.0.246 sends back message to 192.168.2.40 using UDP protocol its shown as UDP protocol, which is correct.But no response from 192.168.2.40 after this.
So i'm assuming it has something to do with the protocol shown as UDP.So if i'm rite i should get that to SIP/SDP.
So my question is how to make this UDP change to SIP/SDP.
The OK you are sending is not valid, it is a SIP protocol violation, and as a result the in-built SIP decoder in Wireshark does not recognise the message as a valid SIP packet.
You should just be responding with $respMessage
Also I highly recommend you use a proper parser for incoming messages and a proper object-oriented writer for constructing outgoing messages. SIP is a (some might say needlessly) complex protocol, you will need more than the small nuggets of information you are extracting to build an endpoint that can do anything even remotely useful.
This small library of mine might make a good base for your parser, and indeed this one almost does exactly what you want if you replace HTTP with SIP.