Home socket comunication - compare C# with Node.js
Reply: 0

socket comunication - compare C# with Node.js

Maciek
1#
Maciek Published in 2017-12-06 22:30:14Z

I'm trying to send TCP message from .Net application to running Matlab script.

Working example of socket client I tested with Matlab server is in Node.js:

var net = require('net');
var client = net.connect({port: 8000},
    function() { //'connect' listener
  console.log('connected to server!');
  var data = 'Message/';
  client.write(data);
});

WireShark sniff for Node.js:

My C# code (rewritten for naked Socket) is:

IPAddress newIpAddress = new IPAddress(16777343);
IPEndPoint ipe = new IPEndPoint(newIpAddress, port);

Socket s =
    new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
s.Connect(ipe);
int byteCount = Encoding.ASCII.GetByteCount(message);
byte[] sendData = new byte[byteCount];
sendData = Encoding.ASCII.GetBytes(message);

s.Send(sendData, byteCount, 0);
s.Disconnect(true);

WireShark sniff for C# (packages from 6 - 9 are diffrent in Seq and Ack):

These two solutions tested for Hercules.exe give the same results.

Why c# solution isn't recived by Matlab server?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.319063 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO