Solved

Sending a List Through Winsock

Posted on 2003-10-29
4
233 Views
Last Modified: 2013-11-13
How do u send a list through winsock!!!

The layout of my app.

Client...

Private Sub CmdConnect_Click()
tcpclient.Connect txtip.Text, 3500
End Sub

Private Sub CmdCollect_Click()
tcpclient.SendData "msg"
' Here i want the code to send the drive's ------------------------------------
End Sub

Server...

Form
--------
Private Sub Form_Load()
tcpServer.Listen
End Sub

Private Sub tcpServer_ConnectionRequest(ByVal requestID As Long)
tcpServer.Close
tcpServer.Accept requestID
End Sub

Private Sub tcpServer_DataArrival(ByVal bytesTotal As Long)
Dim vardata As String
Dim strdata As String
Dim cmddata As String * 3
tcpServer.GetData strdata
cmddata = Left(strdata, 3)
vardata = Right(strdata, Len(strdata) - 3)
DoCommand cmddata, vardata
End Sub

Private Sub tcpServer_Error(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)
On Error Resume Next
tcpServer.Close
tcpServer.Listen
End Sub

Module 1

Public Function DoCommand(command As String, Data As String)  
LCase(command)

Case "msg"
Msgbox "Connected, Requesting Sending Drive List"
' Here i want the code to accept the drive list and add it to a list -----------------------------
End Select
End Function

I want the client to send the case msg which it does then the Client to send the drive list from the form.
The Drive list is frmclient.Drive1
The List on the Server is
frmServer.List1

Thanx in Advance
0
Comment
Question by:iamatramp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 1

Accepted Solution

by:
JonothanTompson earned 150 total points
ID: 9648954
Well i dont know how your planing to get ther drive list but sending the list is simple

*** This Sub creates the list to send
Private Sub CreateList() as String
Dim Total as Integer
Dim Done as Integer
Dim Whole as String
Total = *** insert toal number of drives (or whatever). Ill use Driver(index) from now on
Done = 0
Do until Total = Done
      Whole = Whole & Driver(Done) & VbTab
      Done = Done + 1
Loop
CreateList = Whole
End Function

*** This Sub Splits the List
Private Sub GetList(Whole as String)
Dim Temp as String
Dim Asci as Integer
Dim Drive as Integer
Do Until Len(Whole) = 0
      Temp = Left(Whole, 1)
      Whole = Right(Whole, Len(Whole) - 1)
      If Asci <> 9 Then
            Drive = Drive & Temp
      End If
      If Asci = 9 Then
            lstDrives.AddItem Drive *** This is where you use the information to do whaterver (this one puts it in a list box)
      End If
Loop
End Sub


*** This Code Is For Recieving The Information
Private Sub wskClient(ByVal bytesTotal As Long)
Dim Whole as String
Dim Temp as String
wskClient.GetData Whole
Temp = Left(Whole, 4)
Whole = Right(Whole, Len(Whole) - 4)
Select Case Temp
      Case "DVL_"
            GetList(Whole)
      Case Else
            Debug.Pring Whole
End Select
End Sub


All  the code is there that you will need just some of it you may need to change to suit the way you get the drive information.
A word of warning, i have done this code of the top of my head (comp didnt have VB), it should work.

Any questions just ask

Jonothan Tompson
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question