Author | Message | Time |
---|---|---|
AC_Drkan | I've Tried the C Way and it just bombs with errors does anyone have any "Examples" of how to do this? im Trying to make a bot that will connect to the server and sit in various public chat rooms (aka Clan Recruitment) without a cd-key. | June 16, 2004, 8:57 PM |
Eli_1 | You could use the winsock OCX, but I wrote something that you're probably more used to seeing... [code] Private Const AF_INET = 2 Private Const INVALID_SOCKET = -1 Private Const SOCKET_ERROR = -1 Private Const SOCK_STREAM = 1 Private Const IPPROTO_TCP = 6 Private Const WSA_DESCRIPTIONLEN = 256 Private Const WSA_SYS_STATUS_LEN = 128 Private Const WSA_DescriptionSize = WSA_DESCRIPTIONLEN + 1 Private Const WSA_SysStatusSize = WSA_SYS_STATUS_LEN + 1 Private Type WSAData wVersion As Integer wHighVersion As Integer szDescription As String * WSA_DescriptionSize szSystemStatus As String * WSA_SysStatusSize iMaxSockets As Integer iMaxUdpDg As Integer lpVendorInfo As Long End Type Private Type sockaddr_in sin_family As Integer sin_port As Integer sin_addr As Long sin_zero As String * 8 End Type Private Declare Function WSAGetLastError Lib "wsock32.dll" () As Long Private Declare Function WSACleanup Lib "wsock32.dll" () As Long Private Declare Function Send Lib "wsock32.dll" Alias "send" (ByVal s As Long, buf As Any, ByVal buflen As Long, ByVal flags As Long) As Long Private Declare Function recv Lib "wsock32.dll" (ByVal s As Long, buf As Any, ByVal buflen As Long, ByVal flags As Long) As Long Private Declare Function WSAStartup Lib "wsock32.dll" (ByVal wVR As Long, lpWSAD As WSADataType) As Long Private Declare Function htons Lib "wsock32.dll" (ByVal hostshort As Long) As Integer Private Declare Function socket Lib "wsock32.dll" (ByVal af As Long, ByVal s_type As Long, ByVal protocol As Long) As Long Private Declare Function closesocket Lib "wsock32.dll" (ByVal s As Long) As Long Private Declare Function Connect Lib "wsock32.dll" Alias "connect" (ByVal s As Long, addr As sockaddr, ByVal namelen As Long) As Long Private Declare Function WSAAsyncSelect Lib "wsock32.dll" (ByVal s As Long, ByVal hwnd As Long, ByVal wMsg As Long, ByVal lEvent As Long) As Long Private Declare Function inet_addr Lib "wsock32.dll" (ByVal cp As String) As Long Private Declare Function gethostbyname Lib "wsock32.dll" (ByVal host_name As String) As Long ' Now that all that confusing crap ' is out of the way... Private Sub Form_Load() Dim WSData As WSAData Dim sin As sockaddr_in Dim hSocket As Long Call WSAStartup(&H101, WSData) hSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP) sin.sin_family = AF_INET sin.sin_addr = inet_addr("63.240.202.138") sin.sin_port = htons(6112) If Connect(hSocket, sin, Len(sin)) = SOCKET_ERROR Then ' Error connecting. =[ Else ' Connected! ' Login ' Join channel ' Blah :P Call closesocket(hSocket) End If Call WSACleanup End Sub [/code] | June 16, 2004, 9:23 PM |