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

  1. VERSION 5.00
  2. Object = "{FFACF7F3-B868-11CE-84A8-08005A9B23BD}#1.7#0"; "DSSOCK32.OCX"
  3. Begin VB.Form client 
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "client"
  6.    ClientHeight    =   3300
  7.    ClientLeft      =   1140
  8.    ClientTop       =   1515
  9.    ClientWidth     =   3900
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    PaletteMode     =   1  'UseZOrder
  14.    ScaleHeight     =   3300
  15.    ScaleWidth      =   3900
  16.    ShowInTaskbar   =   0   'False
  17.    Begin VB.TextBox txtHandle 
  18.       Height          =   285
  19.       Left            =   960
  20.       TabIndex        =   9
  21.       Text            =   "handle"
  22.       Top             =   3360
  23.       Width           =   1935
  24.    End
  25.    Begin VB.CommandButton Command1 
  26.       Caption         =   "connect"
  27.       Height          =   255
  28.       Left            =   960
  29.       TabIndex        =   7
  30.       Top             =   3000
  31.       Width           =   1095
  32.    End
  33.    Begin VB.CommandButton Command2 
  34.       Caption         =   "exit"
  35.       Height          =   255
  36.       Left            =   2040
  37.       TabIndex        =   6
  38.       Top             =   3000
  39.       Width           =   855
  40.    End
  41.    Begin VB.TextBox Text4 
  42.       Height          =   285
  43.       Left            =   0
  44.       TabIndex        =   5
  45.       Text            =   "text to say"
  46.       Top             =   2640
  47.       Width           =   3855
  48.    End
  49.    Begin VB.TextBox Text1 
  50.       Height          =   2175
  51.       Left            =   0
  52.       MultiLine       =   -1  'True
  53.       ScrollBars      =   2  'Vertical
  54.       TabIndex        =   4
  55.       Top             =   360
  56.       Width           =   3855
  57.    End
  58.    Begin VB.TextBox Text2 
  59.       Height          =   285
  60.       Left            =   3120
  61.       TabIndex        =   1
  62.       Text            =   "1337"
  63.       Top             =   0
  64.       Width           =   735
  65.    End
  66.    Begin VB.TextBox Text3 
  67.       Height          =   285
  68.       Left            =   960
  69.       TabIndex        =   0
  70.       Text            =   "127.0.0.1"
  71.       Top             =   0
  72.       Width           =   1575
  73.    End
  74.    Begin dsSocketLib.dsSocket dsSocket1 
  75.       Height          =   420
  76.       Left            =   240
  77.       TabIndex        =   8
  78.       Top             =   3000
  79.       Width           =   420
  80.       _Version        =   65543
  81.       _ExtentX        =   741
  82.       _ExtentY        =   741
  83.       _StockProps     =   64
  84.       LocalPort       =   0
  85.       RemoteHost      =   ""
  86.       RemotePort      =   0
  87.       ServiceName     =   ""
  88.       RemoteDotAddr   =   ""
  89.       Linger          =   -1  'True
  90.       Timeout         =   10
  91.       LineMode        =   0   'False
  92.       EOLChar         =   10
  93.       BindConnect     =   0   'False
  94.       SocketType      =   0
  95.    End
  96.    Begin VB.Label Label2 
  97.       Caption         =   "Port:"
  98.       Height          =   255
  99.       Left            =   2640
  100.       TabIndex        =   3
  101.       Top             =   0
  102.       Width           =   375
  103.    End
  104.    Begin VB.Label Label1 
  105.       Caption         =   "IP Address:"
  106.       Height          =   255
  107.       Left            =   0
  108.       TabIndex        =   2
  109.       Top             =   0
  110.       Width           =   855
  111.    End
  112. Attribute VB_Name = "client"
  113. Attribute VB_GlobalNameSpace = False
  114. Attribute VB_Creatable = False
  115. Attribute VB_PredeclaredId = True
  116. Attribute VB_Exposed = False
  117. Private Sub Command1_Click()
  118. On Error Resume Next
  119. If Command1.Caption = "connect" Then
  120.     Command1.Caption = "disconnect"
  121.     Text1 = "   *** connecting to server" & vbCrLf
  122.     dsSocket1.RemoteDotAddr = Text3
  123.     dsSocket1.RemotePort = Text2
  124.     dsSocket1.Connect
  125.     Command1.Caption = "connect"
  126.     dsSocket1.Close
  127.     Text1 = Text1 & "   *** disconnected from server" & vbCrLf
  128. End If
  129. End Sub
  130. Private Sub Command2_Click()
  131. On Error Resume Next
  132. dsSocket1.Close
  133. server.dsSocket1.Close
  134. server.dsSocket2.Close
  135. Unload Me
  136. Unload server
  137. End Sub
  138. Private Sub dsSocket1_Close(ErrorCode As Integer, ErrorDesc As String)
  139. On Error Resume Next
  140. Command1.Caption = "connect"
  141. Text1 = Text1 & "   *** disconnected from server" & Chr(13) & Chr(10)
  142. End Sub
  143. Private Sub dsSocket1_Connect()
  144. Text1 = Text1 & " [connected to server]" & vbCrLf
  145. End Sub
  146. Private Sub dsSocket1_Exception(ErrorCode As Integer, ErrorDesc As String)
  147. On Error Resume Next
  148. dsSocket1.Close
  149. Command1.Caption = "connect"
  150. Text1 = Text1 & vbCrLf & Description & vbCrLf
  151. End Sub
  152. Private Sub dsSocket1_Receive(ReceiveData As String)
  153. On Error Resume Next
  154. Text1 = Text1 & ReceiveData & vbCrLf
  155. 'you could put in some commands if ya wanted..
  156. 'its pretty simple acually ... just do it like chat
  157. 'commands .... split the text up and use a trigger
  158. 'word like "/dns" and then get the text after it
  159. '(the user name to get the IP from) and then have
  160. 'it send the info.
  161. 'hint:  you could make a remote admin. client with
  162.         'the info provided with this.  just code
  163.         'commands in a server and your set.
  164.         
  165. 'have fun with this, and, if someone wants help
  166. 'with this type of program, please either tell them
  167. 'where to get my forms, or send them to them
  168. 'yourself.  be a nice person bout it, dont be like
  169. ' "you need source, code it on your own" cause if
  170. 'you have these forms, that basically means you
  171. 'couldn't do it on your own.  8^)
  172. '       -senate
  173. End Sub
  174. Private Sub Form_Load()
  175. ask1 = InputBox("What would you like your handle to be for chatting?", "handle", "Jon Cromer, Texas Ranger.")
  176. If ask1 = "" Then ask1 = "some guy from Kansas"
  177. txtHandle = ask1
  178. server.txtHandle = ask1
  179. Text3 = dsSocket1.LocalDotAddr
  180. MsgBox "this is just a quick example i made for a friend but then i figured, what the hell, and sent it to kip to post on his site cause he's cool.  he was the first person to post my html editor.  thanks kip.", 55, "omfg!!! words from senate!!! lol"
  181. server.Show
  182. End Sub
  183. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  184. On Error Resume Next
  185. dsSocket1.Close
  186. server.dsSocket1.Close
  187. server.dsSocket2.Close
  188. Unload Me
  189. Unload server
  190. End Sub
  191. Private Sub Text4_KeyPress(KeyAscii As Integer)
  192. If KeyAscii = 13 Then 'if the enter key is pressed
  193.  Packet$ = txtHandle & ":  " & Text4  'puts handle and text together into a string to send
  194.  dsSocket1.Send = Packet$  'sends packet
  195.  Text1 = Text1 & Packet$ & vbCrLf
  196.  Text4 = "" 'clears the textbox
  197.             'of the text in there
  198. End If
  199. End Sub
  200.