Socket issue

I'v been trying to figure out this socket for a loging for the project i'm working on....Here is the VB.NET code::

Socket(Index).SendData(Login(ClientID(Index), Crypt1(Index), Crypt2(Index), Sessionkey(Index)))

This is what i have in C#::

newsock.Send(LoginMod.LoginMod.Login(ref ClientID, ref Crypt1, ref Crypt2, ref SessionKey))

Here is the Error I get on that String::

Error 1 The best overloaded method match for 'System.Net.Sockets.Socket.Send(byte[])' has some invalid arguments

Error 2 Argument '1': cannot convert from 'string' to 'byte[]'



Answer this question

Socket issue

  • Rotte2

    It appears, going by the error message, that your Login() method returns a string.

    The Socket.Send() method is expecting a byte[] parameter and you're trying to pass it a string.

    You need to convert that string into a byte[].

    Lookup System.Text.Encoding.ASCII.GetBytes(string s).

    or....

    Use a StreamWriter:

    StreamWriter sw;

    sw = new StreamWriter(newsock.GetStream());
    sw.WriteLine(LoginMod.LoginMod.Login(...));


  • Socket issue