• Welcome to Valhalla Legends Archive.
 

VB .Net

Started by TriCk, June 12, 2003, 12:46 AM

Previous topic - Next topic

TriCk

Hello,
I've made a bot in vb6 and i find it easy using csb/winsock so ive decided to move onto vb.net is it possible to do the needed coding in vb.net for a successful bot? the winsock connection states etc? if so please explain.  :-\

Thanks

Grok

No.  Microsoft decided that VB6 was too powerful, so part of the design philosophy that went into VB.NET was to reduce complexity at the cost of functionality.  You can still make Windows forms and some file handling, but winsock communications was judged too advanced and removed from VB.NET.  Send your complaints to Redmond, Washington.







(j/k)

Yoni

See MSDN for more info (System.Something.Other.Winsock, I think)

banditxx99

Check System.Net.Sockets namespace.  

You'll have to create your own timer to check for available data in the socket.

Camel

Quote from: banditxx99 on June 12, 2003, 09:12 AM
You'll have to create your own timer to check for available data in the socket.

eww, there's no select()?

K

Just because he doesn't mention it doesn't mean it doesn't exist.

public static void Socket::Select(
  IList checkRead,
  IList checkWrite,
  IList checkError,
  int microSeconds
);


of course, I prefer TcpClient / NetworkStream classes

banditxx99

I usually set up a timer and check the Available property on the socket, if it's > 0, I go get the data.  Would Select forgo the need for a timer somehow?

I checked out TcpClient class.. what's the advantage? Since you still have to convert to/from a byte array anyway, why not use the socket class directly?

Skywing

#7
Quote from: banditxx99 on June 12, 2003, 10:28 PM
I usually set up a timer and check the Available property on the socket, if it's > 0, I go get the data.  Would Select forgo the need for a timer somehow?

I checked out TcpClient class.. what's the advantage? Since you still have to convert to/from a byte array anyway, why not use the socket class directly?
That severely limits response times to incoming data - effectively, you're imposing a minimum of (timer delay) latecy on responses to anything.  Depending on your timer interval, you're either going to be wasting a lot of processor time or noticibly impacting performance.  Win32 is a preemptive multitasking environment; you let the system know that you want to be informed of certain events and allow it to notify you of them, rather than constantly (or periodically) polling for them.  Select typically allows you to block thread execution until a) the specified timer interval elapses, or b) one or more of the events you elected to be notified about occurs.  During this wait time, the thread consumes zero processor time, and the system can promptly wake and resume execution for your thread as soon as said event(s) happen.

K

#8
I don't have a problem dealing with byte arrays, but if you want to read / write strings, you can use the StreamReader / StreamWriter.

using System.IO;
using System.Net.Sockets;
// ...
TcpClient t = new TcpClient();
StreamWriter s;
try
{
    t.Connect( /* .... */ );
    s = new StreamWriter(t.GetStream(), /* character encoding, etc*/);
    s.AutoFlush = true;
    s.Write("hello remote host");
   
}
catch(Exception ex)
}
    Console.WriteLine(ex.ToString());
}