home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / networ1a / server.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-07-16  |  6.7 KB  |  210 lines

  1. VERSION 5.00
  2. Object = "{FFACF7F3-B868-11CE-84A8-08005A9B23BD}#1.7#0"; "DSSOCK32.OCX"
  3. Begin VB.Form server 
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "server"
  6.    ClientHeight    =   2925
  7.    ClientLeft      =   5190
  8.    ClientTop       =   1515
  9.    ClientWidth     =   3870
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    PaletteMode     =   1  'UseZOrder
  14.    ScaleHeight     =   2925
  15.    ScaleWidth      =   3870
  16.    ShowInTaskbar   =   0   'False
  17.    Begin VB.TextBox txtHandle 
  18.       Height          =   285
  19.       Left            =   1200
  20.       TabIndex        =   7
  21.       Text            =   "handle"
  22.       Top             =   3000
  23.       Width           =   1695
  24.    End
  25.    Begin VB.CommandButton Command1 
  26.       Caption         =   "serve"
  27.       Height          =   255
  28.       Left            =   1200
  29.       TabIndex        =   6
  30.       Top             =   2640
  31.       Width           =   855
  32.    End
  33.    Begin VB.CommandButton Command2 
  34.       Caption         =   "exit"
  35.       Height          =   255
  36.       Left            =   2040
  37.       TabIndex        =   5
  38.       Top             =   2640
  39.       Width           =   855
  40.    End
  41.    Begin VB.TextBox Text3 
  42.       Height          =   285
  43.       Left            =   3360
  44.       TabIndex        =   4
  45.       Text            =   "1337"
  46.       Top             =   2280
  47.       Width           =   495
  48.    End
  49.    Begin VB.TextBox Text2 
  50.       Height          =   285
  51.       Left            =   0
  52.       TabIndex        =   3
  53.       Text            =   "text to say"
  54.       Top             =   2280
  55.       Width           =   3255
  56.    End
  57.    Begin VB.TextBox Text1 
  58.       Height          =   2175
  59.       Left            =   0
  60.       MultiLine       =   -1  'True
  61.       ScrollBars      =   2  'Vertical
  62.       TabIndex        =   2
  63.       Top             =   0
  64.       Width           =   3855
  65.    End
  66.    Begin dsSocketLib.dsSocket dsSocket2 
  67.       Height          =   420
  68.       Left            =   360
  69.       TabIndex        =   1
  70.       Top             =   2640
  71.       Width           =   420
  72.       _Version        =   65543
  73.       _ExtentX        =   741
  74.       _ExtentY        =   741
  75.       _StockProps     =   64
  76.       LocalPort       =   1337
  77.       RemoteHost      =   ""
  78.       RemotePort      =   0
  79.       ServiceName     =   ""
  80.       RemoteDotAddr   =   ""
  81.       Linger          =   -1  'True
  82.       Timeout         =   10
  83.       LineMode        =   0   'False
  84.       EOLChar         =   10
  85.       BindConnect     =   0   'False
  86.       SocketType      =   0
  87.    End
  88.    Begin dsSocketLib.dsSocket dsSocket1 
  89.       Height          =   420
  90.       Left            =   0
  91.       TabIndex        =   0
  92.       Top             =   2640
  93.       Width           =   420
  94.       _Version        =   65543
  95.       _ExtentX        =   741
  96.       _ExtentY        =   741
  97.       _StockProps     =   64
  98.       LocalPort       =   1337
  99.       RemoteHost      =   ""
  100.       RemotePort      =   0
  101.       ServiceName     =   ""
  102.       RemoteDotAddr   =   ""
  103.       Linger          =   -1  'True
  104.       Timeout         =   10
  105.       LineMode        =   0   'False
  106.       EOLChar         =   10
  107.       BindConnect     =   0   'False
  108.       SocketType      =   0
  109.    End
  110. Attribute VB_Name = "server"
  111. Attribute VB_GlobalNameSpace = False
  112. Attribute VB_Creatable = False
  113. Attribute VB_PredeclaredId = True
  114. Attribute VB_Exposed = False
  115. Private Sub Command1_Click()
  116. On Error Resume Next
  117. If Command1.Caption = "serve" Then
  118.     Command1.Caption = "stop"
  119.     Text1 = "   *** waiting for a connection" & vbCrLf
  120.     dsSocket1.RemoteDotAddr = "0.0.0.0"
  121.     dsSocket1.LocalDotAddr = "0.0.0.0"
  122.     dsSocket1.RemotePort = Text3
  123.     dsSocket1.Listen
  124.     Text1 = Text1 & "   *** stopped serving" & vbCrLf
  125.     Command1.Caption = "serve"
  126.     dsSocket1.Close
  127.     dsSocket2.Close
  128. End If
  129. End Sub
  130. Private Sub Command2_Click()
  131. On Error Resume Next
  132. dsSocket1.Close
  133. dsSocket2.Close
  134. client.dsSocket1.Close
  135. Unload Me
  136. Unload server
  137. End Sub
  138. Private Sub dsSocket1_Accept(SocketID As Integer)
  139. On Error Resume Next
  140. dsSocket2.Socket = SocketID  'accepts connection
  141. Text1 = Text1 & "   *** serving chat" & vbCrLf
  142. dsSocket1.Close   'closes the listening socket.
  143. End Sub
  144. Private Sub dsSocket1_Exception(ErrorCode As Integer, ErrorDesc As String)
  145. On Error Resume Next
  146. dsSocket1.Close
  147. dsSocket2.Close
  148. End Sub
  149. Private Sub dsSocket2_Close(ErrorCode As Integer, ErrorDesc As String)
  150. On Error Resume Next
  151. Command1.Caption = "serve"
  152. Text1 = Text1 & "   *** client disconnected" & vbCrLf
  153. End Sub
  154. Private Sub dsSocket2_Exception(ErrorCode As Integer, ErrorDesc As String)
  155. On Error Resume Next
  156. dsSocket1.Close
  157. dsSocket2.Close
  158. Text1 = Text1 & vbCrLf & Description & vbCrLf
  159. End Sub
  160. Private Sub dsSocket2_Receive(ReceiveData As String)
  161. Text1 = Text1 & ReceiveData & vbCrLf
  162. If InStr(ReceiveData, "/dns") Then
  163. 'this one will get the ip of another user.
  164. 'example:  /dns nick
  165. theLen$ = Len(ReceiveData) - 5  'gets the len of the nick name
  166. thePerson$ = Right$(ReceiveData, theLen$) 'gets the name of the person
  167.  If LCase(thePerson$) = LCase(txtHandle) Then
  168.  dsSocket2.Send = "user: " & txtHandle & " - " & dsSocket1.LocalDotAddr
  169.  'this part checks to see if the user is you.
  170.  'if it is, it will send your IP# to the chat.
  171.  'how hackerish .. rofl.  (just like irc kids)
  172.  End If
  173. End If
  174. 'you could put in some commands if ya wanted..
  175. 'its pretty simple acually ... just do it like chat
  176. 'commands .... split the text up and use a trigger
  177. 'word like "/dns" and then get the text after it
  178. '(the user name to get the IP from) and then have
  179. 'it send the info.
  180. 'hint:  you could make a remote admin. client with
  181.         'the info provided with this.  just code
  182.         'commands in a server and your set.
  183.         
  184. 'have fun with this, and, if someone wants help
  185. 'with this type of program, please either tell them
  186. 'where to get my forms, or send them to them
  187. 'yourself.  be a nice person bout it, dont be like
  188. ' "you need source, code it on your own" cause if
  189. 'you have these forms, that basically means you
  190. 'couldn't do it on your own.  8^)
  191. '       -senate
  192. End Sub
  193. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  194. On Error Resume Next
  195. dsSocket1.Close
  196. dsSocket2.Close
  197. client.dsSocket1.Close
  198. Unload Me
  199. Unload server
  200. End Sub
  201. Private Sub Text2_KeyPress(KeyAscii As Integer)
  202. If KeyAscii = 13 Then 'if the enter key is pressed
  203.  Packet$ = txtHandle & ":  " & Text2  'puts handle and text together into a string to send
  204.  dsSocket2.Send = Packet$  'sends packet
  205.  Text1 = Text1 & Packet$ & vbCrLf
  206.  Text2 = "" 'clears the textbox
  207.             'of the text in it
  208. End If
  209. End Sub
  210.