connect - A request to send or receive data was disallowed because the socket is not connected C# -



connect - A request to send or receive data was disallowed because the socket is not connected C# -

i trying send username , password authentication response machine getting next error

a request send or receive info disallowed because socket not connected , (when sending on datagram socket using sendto call) no address supplied

static void main(string[] args) { socket sck = new socket(addressfamily.internetwork, sockettype.stream, protocoltype.tcp); sck.bind(new ipendpoint(ipaddress.parse("192.168.5.40"), 10022)); sck.listen(1); socket accepted = sck.accept(); byte[] buffer = encoding.default.getbytes("test post"); accepted.send(buffer, 0, buffer.length, 0); buffer = new byte[255]; int rec = accepted.receive(buffer, 0, buffer.length, 0); array.resize(ref buffer, rec); console.writeline("recieved: {0}", encoding.default.getstring(buffer,24,buffer.length-24)); console.writeline("recieved: {0}", bitconverter.tostring(buffer, 0, 24)); string hexvalues = "00-00-00-01-f8-a0-3d-48-0b-6d-00-00-3d-0a-bf-09-00-00-00-57-00-10-00-00-00"; byte[] hex = stringtobytearray(hexvalues); sck.send(hex, 0, hex.length, 0); sck.close(); accepted.close(); console.read(); }

you effort send info on socket listening incoming connections:

sck.send(hex, 0, hex.length, 0);

you should send through accepted instead:

accepted.send(hex, 0, hex.length, 0);

c# connect server

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -