Help translating C# socket code equivalent Ruby socket code

K

Kamaljeet Saini

Possible to help in translating the following C# socket code to Ruby
socket code please. What specific socket code lines needs to do
following task.

using System.Net.Sockets;
Socket clientSock;

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

receivedBytesLen = clientSock.Receive(Recievbuf, bufoffset, packetsize,
0);

int fileNameLen = BitConverter.ToChar(Recievbuf, 0);

string fileName = "image1.text";//Encoding.ASCII.GetString(Recievbuf, 4,
fileNameLen);

// MessageBox.Show("Client:{0} connected & File {1} started received." +
clientSock.RemoteEndPoint + fileName);

bWrite = new BinaryWriter(File.Open(receivedPath + fileName,
FileMode.Append));

//bWrite.Write(Recievbuf, (int)(352 * 240 * 2 - test),
receivedBytesLen);

bWrite.Write(Recievbuf, bufoffset, receivedBytesLen);

// MessageBox.Show("File: {0} received & saved at path: {1}" + fileName
+ receivedPath);

if (receivedBytesLen != -1)

{

bufoffset += receivedBytesLen;

leftover = toRecv - bufoffset;

if (leftover < packetsize)

{

packetsize = leftover;

}

}
 
M

Mark Thomas

Possible to help in translating the following C# socket code to Ruby
socket code please. What specific socket code lines needs to do
following task.

'help' != 'do it for you'

If you understand the C# code, take a stab at it in Ruby. If you get
stuck, you're more likely to get help. If you don't understand the C#
code, try asking in a different forum. If you don't understand C#,
Ruby, or socket programming then good luck!
 
K

Kamaljeet Saini

The C# code make sense and understandable but the basic ruby socket
lines those could be quite generic to do this, if those are handy to
someone in the forum can save some time and we can try those and
manipulate as needed.

That’s what im look for. If that input we can receive please.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top