[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Help translating C# socket code equivalent Ruby socket code

Kamaljeet Saini

1/29/2009 9:30:00 PM

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;

}

}
--
Posted via http://www.ruby-....

2 Answers

Mark Thomas

1/30/2009 1:19:00 AM

0

On Jan 29, 4:30 pm, Kamaljeet Saini
<kamaljeet_singh_sa...@hotmail.com> 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 Saini

1/30/2009 4:02:00 AM

0

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.
--
Posted via http://www.ruby-....