Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim Socket As Integer 'This means it defines it as a number type rather then being stranded kinda =)
- Private Sub Form_Load()
- Call StartUp
- End Sub
- Private Sub StartUp()
- configFile = ReadINI("server", "host", configFile)
- Dim serverCFG As String, sqlHost As String, sqlPort As Integer, sqlDB As String, sqlUser As String, sqlPassword As String
- Dim lPort As Integer, lDB As String, lUser As String, lPassword As String
- 'Check for Config File
- 'Server Config File
- serverCFG = App.Path & "\settings.ini"
- 'MySQL Config
- sqlHost = ReadINI("mysql", "host", serverCFG)
- sqlPort = ReadINI("mysql", "port", serverCFG)
- sqlUser = ReadINI("mysql", "username", serverCFG)
- sqlPassword = ReadINI("mysql", "password", serverCFG)
- sqlDB = ReadINI("mysql", "database", serverCFG)
- License = ReadINI("mysql", "license", serverCFG)
- 'Check if MySQL Information if correct
- If clsMySQL.checkConnection(sqlHost, sqlPort, sqlDB, sqlUser, sqlPassword) = False Then
- MsgBox "MySQL information or connection is incorrect"
- End
- End If
- 'Checks IF the file exists or not
- If FSO.FileExists("settings.ini") = False Then
- MsgBox "Settings.ini is missing or not found"
- End
- End If
- 'Reads port from settings.ini Config
- PortServ = ReadINI("mysql", "gport", serverCFG)
- 'Shows the text when server Loads
- DebugText ">> prjAmicite, Copyright 2010 [DJQuack]"
- DebugText ">> CLIENT: v9"
- DebugText ">> Server Version: 0.01 (BETA)"
- DebugText ""
- DebugText "Attempting to connect to MySQL."
- clsMySQL.openConnection sqlHost, sqlPort, sqlDB, sqlUser, sqlPassword
- DebugText "Successfully connected to MySQL." & vbNewLine
- 'Makes the Socket listen on the selected port
- sock(0).LocalPort = PortServ
- sock(0).Listen
- DebugText ">> Server is now successfully listening on port: " & sock(0).LocalPort
- DebugText ""
- End Sub
- Private Sub sock_ConnectionRequest(Index As Integer, ByVal requestID As Long)
- Socket = Socket + 1
- Load sock(Socket)
- sock(Socket).Accept requestID
- 'SendData "<packet>" & Chr(1)
- DebugText "Client: [ " & Socket & " ] has successfully connected."
- sock(Socket).SendData "@@" & Chr(1)
- End Sub
- Private Sub sock_DataArrival(Index As Integer, ByVal bytesTotal As Long)
- Dim data As String
- sock(Socket).GetData data
- DebugText "RECIEVED:" & " " & Mid(data, 4)
- data = Mid(data, 4)
- packet_handle.PacketHandler data, Index
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement