Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[VB6] Need help with WinSock

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
bheesham
Advanced Cheater
Reputation: 0

Joined: 08 Nov 2006
Posts: 88
Location: ::1

PostPosted: Sat May 03, 2008 7:19 pm    Post subject: [VB6] Need help with WinSock Reply with quote

If you suffer from mental retardation read this:
NO MY COMPUTER DOES NOT NEED SOCKS!

If you don't suffer from mental retardation read th below:
k. I keep getting an error with winsock 6.0.

this is the code.

Make these:
1 Winsock 6.0 Control and name it user1
1 textbox and name it command
1 listbox and name it users
1 timer and name it rem_users
1 button and name it cmdHide

paste the below into that new form
Code:

'------------------------FORM-----------------------
Dim SocketCounter As Long

Public Sub RemoveListBoxDuplicates(pobjLB As ListBox)
Dim intI As Integer
Dim intJ As Integer
With pobjLB
For intI = 0 To .ListCount - 1
For intJ = .ListCount To (intI + 1) Step -1
If .List(intJ) = .List(intI) Then
.RemoveItem intJ
End If
Next
Next
End With
End Sub





Private Sub cmdHide_Click()
frmUsers.Visible = False
End Sub

Private Sub command_Change()
'make the username function start up
If command.Text = "connect" Then
On Error Resume Next
For n = 1 To SocketCounter
    user1(n).Close
    Unload user1(n)
Next
On Error GoTo t
'closes the socket incase it was open before
user1(0).Close
'sets it to port 5050
user1(0).LocalPort = 5051
'starts to listen for connections
user1(0).Listen
command.Text = ""
command.Refresh
Exit Sub
t:
frmServer.chat = frmServer.chat & "Error : " & Err.Description & vbCrLf
End If
End Sub


Private Sub rem_users_Timer()
RemoveListBoxDuplicates users
End Sub

Private Sub user1_Close(Index As Integer)
'Closes that connection
user1(Index).Close
'unloads that connection
Unload user1(Index)
'puts that into the chat box
chat = chat & "User number: " & Index & " has just disconnected from the chat server." & vbCrLf
End Sub

Private Sub user1_ConnectionRequest(Index As Integer, ByVal requestID As Long)
'increase counter
SocketCounter = SocketCounter + 1
'this will create a new control with index equal to SocketCounter
Load user1(SocketCounter)
'with this we accept the connection and we are now connected to
'the client and we can start sending/receiving data
user1(SocketCounter).Accept requestID
'add to the log
chat = chat & "Client Connected. IP : " & user1(0).RemoteHostIP & " , Client Nick : Client" & sockcounter & vbCrLf
'tell our client his assigned nickname
user1(SocketCounter).SendData "Welcome to PCS (Perfect Chat Server)" & vbCrLf
End Sub

Private Sub user1_DataArrival(Index As Integer, ByVal bytesTotal As Long)
'This is being trigger every time new data arrive
'we use the GetData function which returns the data that winsock is holding
Dim dat As String     'where to put the data
user1(Index).GetData dat, vbString   'writes the new data in our string dat ( string format )
'add the new message to our chat buffer
chat = chat & dat & vbCrLf
'now the client says something, wich arrived at the server...
'the server must now redistibute this message to all other connected
'clients...
On Error Resume Next    'Error Handler
For n = 1 To SocketCounter
    If Not n = Index Then   'we don't want to send the msg back to the sender :)
        If user1(n).State = sckConnected Then   'if socket is connected
            user1(n).SendData dat
        End If
    End If
Next
End Sub

Private Sub user1_Error(Index As Integer, ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
'logs the error
chat = chat & "ERROR!" & vbCrLf & "Description: " & Description & vbCrLf & "Source: " & Err.Source
'closes the connection
user1_Close Index
'you could also use user1(Index).close function but i
'prefer to call it within the user1_Close functions that
'handles the connection closing in general
End Sub



Here is the error i get.



please help me fix this error...
Back to top
View user's profile Send private message Visit poster's website
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8588
Location: 127.0.0.1

PostPosted: Sat May 03, 2008 8:47 pm    Post subject: Reply with quote

You have "Index as Integer" as a param, but, your Winsock control is not an array, but a single control. Notice in your picture, the index property is blank? Set it to a number if you plan to index the control.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Estx
Expert Cheater
Reputation: 0

Joined: 04 Mar 2008
Posts: 172

PostPosted: Sat May 03, 2008 11:05 pm    Post subject: Reply with quote

Wiccaan wrote:
You have "Index as Integer" as a param, but, your Winsock control is not an array, but a single control. Notice in your picture, the index property is blank? Set it to a number if you plan to index the control.


If you don't plan to index it, then remove "Index As Integer" from between the parenthesis.
Back to top
View user's profile Send private message
bheesham
Advanced Cheater
Reputation: 0

Joined: 08 Nov 2006
Posts: 88
Location: ::1

PostPosted: Sun May 04, 2008 1:25 pm    Post subject: Reply with quote

when i take out the "Index as Integer" this is the error it gives me.

Back to top
View user's profile Send private message Visit poster's website
bheesham
Advanced Cheater
Reputation: 0

Joined: 08 Nov 2006
Posts: 88
Location: ::1

PostPosted: Sun May 04, 2008 3:16 pm    Post subject: Reply with quote

.... -_-''.... it works. i got something similar to this to work.

here is a source from pheonixbit or whatever. They got it to work perfectly. mine is based of of it.

what it is supposed to be able to do is to recieve the names of users and their ip address.

when the user send's the info, the server gets it and relays it back to all of the connected users.


refresh if you cant see attachment



The Extension 'zip' was deactivated by an board admin, therefore this Attachment is not displayed.

Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites