HELP! Winsock SendData and String 
Author Message
 HELP! Winsock SendData and String

Hi,

can someone please help me with SendData?
I have a structure I need to send from server to client. Since I cannot
send structure - I encode everything into a string, like this:

Dim myStr as String * 128;

Mid(myStr,1) = id
Mid(myStr,2) = length ... and so on

Now, I have winsock control name winsock0

How do I send the string I created??? I tried winsock0.SendData myStr
and it gives me a run time error. (winsock0 is initialized, connected,
and so on - so it is not that)

Also, if I know the exact structure that client should send me - how can
I send the whole thing without encoding it into a darn string first????


REALLY slow here (Japan)
Thanks,
Vic



Mon, 28 Aug 2000 03:00:00 GMT  
 HELP! Winsock SendData and String

Hello Victor,

You will have to come with your own data converntion, i mean you will decide
if you had to send id,name,Lastname

then during sending you have your own format e.g.
10001:Victor:Lastname
e.g. str = 1001:Victor:Lastname

so you have a delimeter and you know what the format style is

now you set the winsock controls remote port to the local port of the
winsock on server
Winsock1.RemotePort = 1001
Winsock1.RemoteHost = Hostname
Winsock1.Connect
Do while Winsock1.State <> 7 ''7=connected
    Doevents
Loop
winsock1.SendData str
doevents

Hope this helps.
All the Best



Tue, 29 Aug 2000 03:00:00 GMT  
 HELP! Winsock SendData and String

Do you mean to tell me that
if I have
port as integer
name as string
lastname as string
str as string

and post= 1001
    name = "Victor"
    lastname = "Shvetsky"

then I can simply say:
str = post:name:lastname

and winsock1.senddata str?

But when I receive it - how can I get it out???
thanks,
vic

Quote:

> Hello Victor,

> You will have to come with your own data converntion, i mean you will decide
> if you had to send id,name,Lastname

> then during sending you have your own format e.g.
> 10001:Victor:Lastname
> e.g. str = 1001:Victor:Lastname

> so you have a delimeter and you know what the format style is

> now you set the winsock controls remote port to the local port of the
> winsock on server
> Winsock1.RemotePort = 1001
> Winsock1.RemoteHost = Hostname
> Winsock1.Connect
> Do while Winsock1.State <> 7 ''7=connected
>     Doevents
> Loop
> winsock1.SendData str
> doevents

> Hope this helps.
> All the Best



Sun, 03 Sep 2000 03:00:00 GMT  
 HELP! Winsock SendData and String

Hi Victor

The explaination and code below assumes you have all the declared variables,
winsock control named winsock1, a client side, a server side.

Here what you need to do:

At the Client Side:

lastname = "Merchant"
firstname = "Shajahan"
Age         = "22'
str = lastname & ":" & firstname & ":" & Age ''Merchant:Shajahan:22

winsock1.remoteport = 1001
winsock1.remotehost = hostname
winsock1.connect

do while winsock1.state <> 7 ''wait till connected
    Doevents
loop

winsock1.senddata str
winsock1.close

Thats it at client side.

At Server Side:
''in form_load:
Winsock1.LocalPort = 1001
Winsock1.Listen

''then accept connection in
''in connection_request
winsock1.accept repuest_id

''in winsock1_Dataarrival
dim indata as string
winsock1.GetData indata
''now you have the string sent by client in the variable indata


hope this helps
All the best

(Please verify the exact syntax ,mthods and events that are stated above.)



Sun, 03 Sep 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. winsock problem sending large strings (winsock.senddata)

2. Sending multiple strings with SendData (Winsock)

3. Winsock: DataArrival combines multiple SendData strings

4. VB6: Winsock senddata problem - help!

5. WInsock SendData problem HELP

6. winsock.senddata nntp rfc, help?

7. winsock1.senddata STRING - Help me, please.

8. SendData and Winsock control collection ?

9. winsock senddata problem/question

10. Weird thing with Winsock.SendData

11. Winsock.SendData

12. WinSock SendData Error

 

 
Powered by phpBB® Forum Software