Solved

Sending a List Through Winsock

Posted on 2003-10-29
4
249 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

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

617 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