Socket code examples

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Socket code examples

Kevin Brooks-2
For some reason I have not been able to get inter-application data passing
using sockets to work.  Is there sample code that I can see?  My needs are
as follows.

I wrote a large Mac Rev app that does a lot of media playing and
manipulation.  A work colleague has written a Mac application in java around
some data processing algorithms of his. The project is to have his app
control my app.  Since my app can take keyboard entry to control its media
and windows, our idea was to establish a socket connection between the two
apps, with his app sending chars to mine, and my app would interpret them
like keydown events.  However, due to geographic distance, we need to do our
respective development separately, sharing apps via email.

All I want to do is create a test app that opens a socket on a specified
port and listens (reads) that port, displaying what it reads in a field.
Once successful, I'll transfer that working code to my main media app.  I
want to make a second test app that opens a port and sends data to the first
test app.  Pretty simple.  A shortened version of previous assumptions
(according to the documentation) are:

The Reading App:
 put "127.0.0.1:50101" into lsocketID
 accept connections on port lsocketID with message "connectionmade"

Where connectionmade will call itself every xxx millisecs
  read from socket lsocketID for 5 with message "displayreaddata"


The Sending App:
  put "127.0.0.1:50101" into lsocketID
  open socket to lsocketID with message "connectionmade"

And once the connection is made, a btn script will trigger data to be sent
from a field:
  put fld "datafld" into sendingdata
  write sendingdata to socket lsocketID with message "writeconfirm"

This is how I understood it works, but clearly I'm wrong.  I got things to
sort of work using the "datagram" form of the accept and open statements,
but not well.  Some sample code would be much appreciated.

Thanks,
Kevin

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: Socket code examples

Brian Yennie
Kevin,

Try:

> put "50101" into lsocketID

instead of:

> put "127.0.0.1:50101" into lsocketID

HTH,
Brian


_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: Socket code examples

masmit
In reply to this post by Kevin Brooks-2
Kevin, you don't  specify the IP address in the listener, so just:

accept connections on port 50101 with message "connectionmade"

then, when the connection is made, the socket id (which is not the  
same as the port number) is sent as a parameter to the  
"connectionmade" handler:

on connectionmade pSocket
      read from socket pSocket for 5 with message "displayreaddata"
      if not exitCondition then
        send "connectionmade  pSocket" to me in 100 millisecs
      else
        close socke pSocket
      end if
end connectionmade

Best,

Mark

On 18 Jun 2008, at 02:55, Kevin Brooks wrote:

> For some reason I have not been able to get inter-application data  
> passing
> using sockets to work.  Is there sample code that I can see?  My  
> needs are
> as follows.
>
> I wrote a large Mac Rev app that does a lot of media playing and
> manipulation.  A work colleague has written a Mac application in  
> java around
> some data processing algorithms of his. The project is to have his app
> control my app.  Since my app can take keyboard entry to control  
> its media
> and windows, our idea was to establish a socket connection between  
> the two
> apps, with his app sending chars to mine, and my app would  
> interpret them
> like keydown events.  However, due to geographic distance, we need  
> to do our
> respective development separately, sharing apps via email.
>
> All I want to do is create a test app that opens a socket on a  
> specified
> port and listens (reads) that port, displaying what it reads in a  
> field.
> Once successful, I'll transfer that working code to my main media  
> app.  I
> want to make a second test app that opens a port and sends data to  
> the first
> test app.  Pretty simple.  A shortened version of previous assumptions
> (according to the documentation) are:
>
> The Reading App:
>  put "127.0.0.1:50101" into lsocketID
>  accept connections on port lsocketID with message "connectionmade"
>
> Where connectionmade will call itself every xxx millisecs
>   read from socket lsocketID for 5 with message "displayreaddata"
>
>
> The Sending App:
>   put "127.0.0.1:50101" into lsocketID
>   open socket to lsocketID with message "connectionmade"
>
> And once the connection is made, a btn script will trigger data to  
> be sent
> from a field:
>   put fld "datafld" into sendingdata
>   write sendingdata to socket lsocketID with message "writeconfirm"
>
> This is how I understood it works, but clearly I'm wrong.  I got  
> things to
> sort of work using the "datagram" form of the accept and open  
> statements,
> but not well.  Some sample code would be much appreciated.
>
> Thanks,
> Kevin
>
> _______________________________________________
> use-revolution mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution