Opening a socket and sending/receiving plain text

Community based support for the Digium Phone Application Programming Interface (API).

Moderators: jwitt, sruffell, malcolmd, Moderator

Opening a socket and sending/receiving plain text

Postby wallnutmonkeys » Tue Jun 11, 2013 6:09 am

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
wallnutmonkeys
Newsterisk
 
Posts: 28
Joined: Thu Feb 10, 2011 9:52 pm

Re: Opening a socket and sending/receiving plain text

Postby sruffell » Tue Jun 11, 2013 8:37 am

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
sruffell
Oldsterisk
 
Posts: 200
Joined: Fri Jan 07, 2011 2:02 pm

Re: Opening a socket and sending/receiving plain text

Postby wallnutmonkeys » Tue Jun 11, 2013 9:08 am

Thanks Shaun, I will look that up and do a few tests.

cheers
wallnut
wallnutmonkeys
Newsterisk
 
Posts: 28
Joined: Thu Feb 10, 2011 9:52 pm


Return to Digium Phone API

Who is online

Users browsing this forum: Google [Bot] and 1 guest