Advertisement
Guest User

Untitled

a guest
Jul 5th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Dim Socket As Integer 'This means it defines it as a number type rather then being stranded kinda =)
  2. Private Sub Form_Load()
  3.     Call StartUp
  4. End Sub
  5. Private Sub StartUp()
  6.     configFile = ReadINI("server", "host", configFile)
  7. Dim serverCFG As String, sqlHost As String, sqlPort As Integer, sqlDB As String, sqlUser As String, sqlPassword As String
  8. Dim lPort As Integer, lDB As String, lUser As String, lPassword As String
  9.  
  10. 'Check for Config File
  11. 'Server Config File
  12.     serverCFG = App.Path & "\settings.ini"
  13. 'MySQL Config
  14.    sqlHost = ReadINI("mysql", "host", serverCFG)
  15.     sqlPort = ReadINI("mysql", "port", serverCFG)
  16.     sqlUser = ReadINI("mysql", "username", serverCFG)
  17.     sqlPassword = ReadINI("mysql", "password", serverCFG)
  18.     sqlDB = ReadINI("mysql", "database", serverCFG)
  19.     License = ReadINI("mysql", "license", serverCFG)
  20. 'Check if MySQL Information if correct
  21. If clsMySQL.checkConnection(sqlHost, sqlPort, sqlDB, sqlUser, sqlPassword) = False Then
  22.     MsgBox "MySQL information or connection is incorrect"
  23.     End
  24. End If
  25. 'Checks IF the file exists or not
  26. If FSO.FileExists("settings.ini") = False Then
  27.     MsgBox "Settings.ini is missing or not found"
  28.     End
  29. End If
  30. 'Reads port from settings.ini Config
  31.    PortServ = ReadINI("mysql", "gport", serverCFG)
  32. 'Shows the text when server Loads
  33.    DebugText ">> prjAmicite, Copyright 2010 [DJQuack]"
  34.     DebugText ">> CLIENT: v9"
  35.     DebugText ">> Server Version: 0.01 (BETA)"
  36.     DebugText ""
  37.     DebugText "Attempting to connect to MySQL."
  38. clsMySQL.openConnection sqlHost, sqlPort, sqlDB, sqlUser, sqlPassword
  39.     DebugText "Successfully connected to MySQL." & vbNewLine
  40. 'Makes the Socket listen on the selected port
  41.    sock(0).LocalPort = PortServ
  42.     sock(0).Listen
  43.     DebugText ">> Server is now successfully listening on port: " & sock(0).LocalPort
  44.     DebugText ""
  45. End Sub
  46.  
  47. Private Sub sock_ConnectionRequest(Index As Integer, ByVal requestID As Long)
  48.      Socket = Socket + 1
  49.      Load sock(Socket)
  50.      sock(Socket).Accept requestID
  51. 'SendData "<packet>" & Chr(1)
  52.     DebugText "Client: [ " & Socket & " ] has successfully connected."
  53.      sock(Socket).SendData "@@" & Chr(1)
  54. End Sub
  55.  
  56. Private Sub sock_DataArrival(Index As Integer, ByVal bytesTotal As Long)
  57. Dim data As String
  58. sock(Socket).GetData data
  59. DebugText "RECIEVED:" & " " & Mid(data, 4)
  60. data = Mid(data, 4)
  61. packet_handle.PacketHandler data, Index
  62. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement