Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Socket Connect Error


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   -  Reputation: 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.


Sponsor:



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.



PARTNERS