Page 1 of 1

Opening a socket and sending/receiving plain text

PostPosted: Tue Jun 11, 2013 6:09 am
by wallnutmonkeys
Hi everyone, just started developing using the api. I was wondering what class I should be using to open a TCP connection to a remote host, and exchanging plain text to and from that host. I was having a look at the netrequest object, but it seems to be for http requests. If anyone has a hint on where I should start digging it would be much appreiciated.

thanks in advance
wallnut

Re: Opening a socket and sending/receiving plain text

PostPosted: Tue Jun 11, 2013 8:37 am
by sruffell
Hi wallnut,

There are only two ways for an app to communicate with outside servers and neither of them allow you to open direct sockets.

NetRequest is the one that users will be most familiar. Like browsers before the advent of WebSockets, you can use long polling to simulate socket-like communications.

The other way to communicate with a server is to use pbx.request to send SIP messages that, if you're using Asterisk, you can then pass over AMI to your custom server application. See the section *Custom Applications and the DPMA* on the Custom Phone Applications with DPMA page for an example.

Cheers,
Shaun

Re: Opening a socket and sending/receiving plain text

PostPosted: Tue Jun 11, 2013 9:08 am
by wallnutmonkeys
Thanks Shaun, I will look that up and do a few tests.

cheers
wallnut