Help translating C# socket code equivalent Ruby socket code

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;

}

}

On Jan 29, 4:30 pm, Kamaljeet S.
[email protected] wrote:

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!

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.