Can't receive data

VictorP

Newcomer
Joined
Dec 23, 2003
Messages
1
HI ALL! Can you help me?
:mad:
:confused: :confused:
I'm try this:
I have class with these methods:
public void Connect()
{
try
{
//create a new client socket ...
mySocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
String szPort = sPort.ToString();
int alPort = System.Convert.ToInt16 (szPort,10);
System.Net.IPAddress remoteIPAddress = System.Net.IPAddress.Parse(sHost);
System.Net.IPEndPoint remoteEndPoint = new System.Net.IPEndPoint(remoteIPAddress, alPort);
mySocket.Connect(remoteEndPoint);
}
catch (SocketException se)
{

}
}

public String sendCommandR(String comm)
{
String res = "";
try
{
Object objData = comm;
byte[] byData = System.Text.Encoding.ASCII.GetBytes(objData.ToString ());
mySocket.Send(byData,0,byData.Length, SocketFlags.None);
byte [] buffer = new byte[1024];
int iRx = 0;
iRx = mySocket.Receive(buffer, 0, mySocket.Available, SocketFlags.None);
char[] chars = new char[iRx];
System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();
int charLen = d.GetChars(buffer, 0, iRx, chars, 0);
System.String szData = new System.String(chars);
res = splitRes(szData);
mySocket.Close();
}
catch (SocketException se)
{
res = "";
}
return res;
}

data string go without problems, but i can receive data from remote host. Why? Help me.
 
Back
Top