0

I have 2 questions:

question (1): I want to connect my Gadgeteer who works on .net micro framework v4.2 via TCP to a server i wrote on node.js, but I am just stuck on

socket.Connect(new IPEndPoint(IPAddress.Parse(ip_address), port)); it's just loading. I have an ethernet module and I read at https://netmf.codeplex.com/releases/view/81000 under the title bug fixes that "Socket.Connect still blocked after reinsert ethernet cable" have this been fixed or not?

The code is:

 Connecttoserver(settings.IPAddress, 8000);

       void Connecttoserver(string ip_address, int port)
     {
          try
           {

socket = new Socket(AddressFamily.InterNetwork, 
                              SocketType.Stream, 
                                      ProtocolType.Tcp);

               socket.Connect(new IPEndPoint(IPAddress.Parse(ip_address), port));

               Send("HI !");

               ReceiveThread = new Thread(Receive);

               ReceiveThread.Start();



           }

          catch (Exception x)
           {


           }


       }

Question (2):

I want to use socket.io who is using websockets instead of TCP/IP but when I try the example from this webside https://github.com/nikkis/SocketIO.NetMF/. I can see in the output that the message has been sent but nothing happens, the server is never connected to my Gadgeteer? Can somebody help me with a socket.io server who send data to the client directly not to the browser. is that possible with socket.io in node.js?

Sam
  • 3
  • 3

1 Answers1

0

To your question (2):

Which version of Socket.IO you have for Node.js? I think the library supports version 0.9.x. Can you tell what your Node.js logs say when you try to connect your Gadgeteer? Does it receive connection event? Bellow an example to set up Node.js socket.io that should work with the library.

var server = APP.listen( config.server.port );
var io = socket.listen( server );

io.sockets.on( 'connection', function( socket ) {
  console.log( 'connection' );

  socket.on( 'disconnect', function( deviceid ) {

    console.log( 'disconnecting ' + socket.id );

  } );

  socket.on( 'my_own_event', function( param1, param2 ) {

    console.log( 'executing my own event' );

  } );

}
nikkis
  • 16
  • 2
  • Hi Nikkis,can you please explain what is APP? I get error because of it. var server = APP.listen( config.server.port );. My other socket.io server does not recive any thing it's just unconnected to the client even if both the client and the server works without errors :/ – Sam Oct 31 '14 at 19:17
  • APP is express app: var app = express(); app.use( express.bodyParser() ); var socket = require( 'socket.io' ); app.configure( function() { app.use( express.static( ROOT + '/' ) ); } ); – nikkis Nov 04 '14 at 13:16
  • nikkis I'm using your socket.io library. when i get a message the message shows on output via public virtual void onMessage(string message) { Debug.Print("got messag: " + message); }. but I want to use the data(Message). can you pleas help me with that? best Regards Sam – Sam Nov 05 '14 at 17:00
  • The Socket.IO was implemented and test with my other project name Orchestrator.js (Node.js based coordination platform, http://orchestratorjs.org), which codebase is available from https://github.com/nikkis/OrchestratorJS. Maybe this will help you. Sending a data event with arguments should work with: var methodArguments = [’arg1’, ’arg2’ ]; socket.emit( 'methodcall', methodArguments ); – nikkis Nov 06 '14 at 09:05
  • do you mean var methodArguments = [’arg1’, ’arg2’ ]; on the server and socket.emit( 'methodcall', methodArguments ); is that on gadgeteer ? – Sam Nov 06 '14 at 16:40
  • no, both on server. I'm not sure if I understood your question correctly. What data(Message) you want to use, and on which side, server or client. – nikkis Nov 07 '14 at 17:39
  • Hi nikkis is it ok for you if I use your socketIO projekt example on https://github.com/nikkis/SocketIO.NetMF for my project? – Sam Nov 14 '14 at 15:46
  • Yes, definitely. That's why it is open source ;-) btw. if I my answers helped you, could you kindly vote ;-) – nikkis Nov 17 '14 at 08:52
  • Thank you! :) definitely I will! – Sam Nov 17 '14 at 09:59