Forum: Ruby Help translating C# socket code equivalent Ruby socket code

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Kamaljeet S. (Guest)
on 2009-01-29 23:32
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;

}

}
Mark T. (Guest)
on 2009-01-30 03:22
(Received via mailing list)
On Jan 29, 4:30 pm, Kamaljeet S.
<removed_email_address@domain.invalid> 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!
Kamaljeet S. (Guest)
on 2009-01-30 06:04
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.
This topic is locked and can not be replied to.