Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Anyone looking for a way to modernize legacy data or easily migrate to a more cost-effective database without sacrificing functionality will benefit from this seminar. View the Intro to Advantage Database Server now!
  #1  
Old March 2nd, 2003, 05:01 PM
kaos77 kaos77 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Atlanta, GA
Posts: 5 kaos77 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to kaos77
data loss over winsock connection

i have 2 pretty simple programs, one acting as a server (listening on a certain port on my pc) and another as client (also running on my pc connecting to 127.0.0.1 on the server's port)....

they connect fine, and i have message boxes set up to show me what data is doing what...it appears that the data string i am trying to SEND to the server is fine, but once the server gets the data it instantly turns it into "????????????????"....

it also seems that the procedure gets confused as it never sends any data back to the client (which it is supposed to do) and my client program ends up timing out (it has a 30 second timer)....

here is the data arrival procedure in the server....
Quote:
Private Sub wsCom_DataArrival(Index As Integer, ByVal bytesTotal As Long)
On Error Resume Next
If bytesTotal > 0 Then
Dim retData
Dim TUData As Variant
Dim logOK As Boolean
Dim usrName
Dim usrSrvr
Dim usrPWd
Dim usrIpAdd
Dim addNo

wsCom(Index).GetData retData
MsgBox retData
TUData = Split(retData, "|")
usrName = TUData(0)
usrPWd = TUData(1)
usrIpAdd = wsCom(Index).RemoteHostIP
usrSrvr = TUData(3)

'add them to the user que
lstQueUsr.AddItem usrName & " - " & usrIpAdd & " - " & usrSrvr

checkLogin usrName, usrPWd, usrIpAdd, usrSrvr, intMax

End If

End Sub


This is the procedure in the Client that sends the data to the server

Quote:
Dim cliStr
cliStr = txtUsrId.Text & "|" & txtUsrPw.Text & "|" & Winsock1.LocalIP & "|" & "mainSrv"
Winsock1.SendData cliStr
MsgBox "We are connected and have sent the following data" & vbCrLf & vbCrLf & cliStr
cmdLogin.Enabled = False
txtUsrId.Enabled = False
txtUsrPw.Enabled = False


thanks for any help on this, its about to drive me insane....

Reply With Quote
  #2  
Old March 3rd, 2003, 01:44 PM
customfittech customfittech is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: St. Louis, MO USA
Posts: 43 customfittech User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
I don't have time to try out your code, but I can offer some suggestions.

1. Outgoing is ok, you're sending a string, so that's simple.
2. Incoming procedure is where the problem is. Your getting a Byte Array, not a string, so when your code implicitly converts the output from your getdata method in the object call:

wsCom(Index).GetData retData

What really happens is, you get something like this in the ByteArray first (in memory only)

bArray(0) = 0
bArray(1) = 14
bArray(2) = 0
bArray(3) = 32
... etc

Zeros, separated by the chars in Ascii code.

This is an Array that can probably be decoded using the following code converting FROM unicode to a non-unicode string.

Dim sOutput as String
sOutput = StrConv( wsCom(Index).GetData retData, vbFromUnicode )

Msgbox sOutput

May work, may not. Just a guess....
__________________
- Chris of Custom Fit Technology
http://www.customfittech.com

Access to MySQL Conversion Tool,
Visual XSLT Conversion Tool

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > data loss over winsock connection


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway