Hi!

Im having a problem in the next line:

i = socket.Receive(buffer)

buffer is defined as: byte[] buffer = new byte[1024];

It crash when its waiting for the answer.

In c++ im sending this:

len = send(sock,"hola",4,0);

Any idea?

Thanks

Recommended Answers

All 3 Replies

Do you open the socket? We'll need more code to see what might be the problem.

Yeah, socket is well open beacuse first i tried to send a string, and the string go well.

getSocket(numsock).socketSend("filemanager"); --> this is ok, beacuse server recive the string.
 Console.WriteLine(getSocket(numsock).socketRecv()); --> I will put down the method code
public string socketRecv()
        {
             buffer = new byte[1024];
                        i = socket.Receive(buffer); --> Here crash 
                        string recibido = System.Text.Encoding.UTF8.GetString(buffer);
                        return recibido;

        }

Solved !!
I had a loop o "receive()" in other thread of other class xD

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.