Jump to content

View more

Image of the Day

The night is still, but the invasion brings chaos. #screenshotsaturday #hanako #indiegame #gameart #ue4 #samurai https://t.co/cgILXuokoS
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Socket Connect Error

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
No replies to this topic

#1 MattyG08   Members   

102
Like
0Likes
Like

Posted 28 June 2014 - 10:42 PM

Howdy Folks!

I've been having this really odd error. I cannot seem to identify what it is, if you wouldn't mind giving me a little help here It would be much appreciated!

      public void MiscCommand(string cmd, string target)
        {
            Socket cn = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            byte[] data = Encoding.ASCII.GetBytes(cmd);
            cn.Connect(target, 7772); // target is the string containing the target IP for the message
            cn.Send(data);
            Log("Sent: " + cmd + " to IP:" + target);
            cn.Close();
        }

The Error I am picking up is simply this:

relating to "target"
Specified argument was out of the range of valid values.
Parameter name: The size of hostName is too long. It cannot be longer than 126 characters.

Even though the string is only "192.168.1.2"

What's the dealio guys!? is it just returning this because it is not being picked up by the client or what?

Much appreciated!

 

Also, I'm using .NET Framework 3.5

P.S If I manually put in the IP Address it works perfectly, it just does not appear to be working with the 'target' string..

 

I also used DNS.GetHostByAddress(target) but that is reporting "An invalid IP address was specified." even though if I manually put in the IP it

It may be something to do with the Encoding.ASCII.GetString(_cbuffer), it might be generating invisible whitespace - yep that was it

 

edit: It's working, the buffering string I received had a massive byte length and I just had to Isolate the IP from the surrounding whitespace. :P


Edited by MattyG08, 28 June 2014 - 11:15 PM.





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.