Help using easysockets?-VBForums
Results 1 to 5 of 5

Thread: Help using easysockets?

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2012
    Posts
    14

    Help using easysockets?

    http://www.vbforums.com/showthread.p...t=#post3852009

    I'm just starting out with tcp on vb.net (2010 exp) and I'm having a heck of a time understanding how it all works. I sure do miss WinSock on VB6

    ANyway, I found the above class and it looks promising but I can't figure out how to use it. Actually, I can't seem to get past declaring it (ugh, newbs!)

    I tried

    private withevents myConnection as easysocket = new easysocket

    <later>
    myConnection.Address = myTCPAddress.tostring
    myConnection.Port = str(myPort)
    myConnection.Connect

    I just get object not set...

    If anyone has experience with this I'd love to see a little sample!

    Thanks

  2. #2

    Thread Starter
    New Member
    Join Date
    Dec 2012
    Posts
    14

    Re: Help using easysockets?

    Oh, I should mention. I think the object might be the sub for the OnConnectionEstablished event - I looked through the class and didn't see where I could pass the sub address to the class so I just made a sub :

    ConnectionEstablished(ea As easySocket.DataReadEventArgs)

    It was a wild guess and probably wrong 8(

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2012
    Posts
    14

    Re: Help using easysockets?

    Ok, while driving it dawned on me that the class is raising an event in exactly the same way as a forms control (which is a class). I changed my subs to something like this (cant remember the exact names)

    private sub DataReceiver(sender as Object, e as System.EventArgs) handles MyConnection.DataReceived

    That hasn't solved the error I get as soon as I click the connect button. It actually says object not set to an instance of an object but doesn't indicate where in the code this is happening. I'm assuming since the only thing I changed in my existing code is the myConnection parts it's something in the newly created myConnection object...

  4. #4

    Thread Starter
    New Member
    Join Date
    Dec 2012
    Posts
    14

    Re: Help using easysockets?

    Well no surpise - it was me. I was supplying myTCPAddress.tostring but I'd cut out the myTCPAddress declaration when I removed my old tcpclient code. Odd that the debugger didn't home in on the offending assignment.

    Still have one problem which I'm pretty sure isn't me (exactly). I'm trying to disconnect and using myConnection.close() (which is TCPClient.close()) but the easysocket EndARRead method throws an exception when it tries an EndRead() after the close. I'm assuming either it's not supposed to do that last endread or .Close() is the wrong way to disconnect. I can't find anything else to use to disconnect from the server though.

    Any thoughts?

  5. #5
    Loquacious User Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    24,778

    Re: Help using easysockets?

    It shouldn't be calling EndRead after the close, but it may not matter, either. Any activity with a network connection should be performed in a Try...Catch block, because exceptional circumstances will happen. You may have already figured out a solution to this, or you may have wandered off. In any case, I have found that there are some exceptions related to network issues that are worth just swallowing without making the effort to fix them. This doesn't seem to be such a case, though, since it appears to be clearly a case of code being out of order.
    My usual boring signature: Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.