Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Is The Way 2 Send Data & Get Data Like Winsock Do....... W/o Using Winsock Control ?


Is the way 2 send data & get data like winsock do....... w/o using winsock control ?


thnx in advance!!




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Winsock Control Send Data In A Loop
Hello,
I am using a winsock control to talk to a server. It is working ok. But I have to send and recieve data several time. So what I am doing is:

1. Open a connection.
2. send the data.
3. recieve the data.
4. then write a loop to send data x times and recieve after every send.
5. close the connection.

5. How is it possible? any ideas? Do I have to wait for the data arrival event to fire up after every so often using doEvents or timer or sleep? Is it possible to do something like this:

for int i = 0 to 10
winsock.send(data)
next i
Please help..

Forcing A Winsock Control To Send Its Data Immediately
Hello,

I'm working on a networked game that uses winsock version 6.0 controls for both the client and the server. What I'm doing now is this:

mywinsock.senddata "DATA!"
DoEvents

I'm using the call to DoEvents to force the data out, but this often times makes other events fire as well.

I'm wondering what would be a better way to force the winsock control to send its data.

TIA
Brian



Edited by - supernaut_1000 on 5/23/2004 8:12:08 PM

How Do I Send Data Through Winsock
hi guys im developing a client server application that will need multiple clients...i need to send the time and date of the server out to all the client to keep in synce with the server..can anyone give me the code to do this?? please help me out im desperate!!

How To Send Data On Winsock....
Quote:




Open "C:Programs Filespicture.jpg For Binary As #1

If strLOF - Loc(1) < 2040 Then 'if you are at the last chunk of data
strblock = Space$(strLOF - Loc(1)) 'sets the block size to the size of the data (cause its less!)

Get 1, , strblock 'gets data
sckserver.SendData "File" & strblock






partial code right here.....successful send the picture however fail to display

When Does Winsock Send Data?
I've been doing some work where I respond to the client's incoming data by sending data, and it seems that all calls that I make to send data don't execute until all code within the data arrival winsock method are executed. Is this how it works once compiled or is it just a quirk of the IDE?

How To Send Data Through Winsock??? Please Help!
I'm trying to send a response back to the device that sent my VB program data. I've used the winsock control method .SendData

How do I test whether is worked or not? I don't know how to test this. Any tips are appreciated.

Thanks,
j

Using Winsock To Send Data
Hi

I'm having some trouble sending data with winsock.

My client application will send data to my server application.

I user TCPconnect.SendData ("abc...") etc.

I use a sub proecdure to find out what the client has send. All messages are prefixed with a 5 character code.

Then the server will do something according to what it recieved.

The problem I get is that sometimes the client needs to send 2 bits of data.

i.e.

TCPconnect.SendData ("blah blah")
TCPconnect.SendData ("blah2 blah2")

But the server will recieve "blah blahblah2 blah2"

Is there anyway to make sure that the data has been sent before it sends the next string?

I've tried putting DoEvents inbetween the two SendData commands, but that doesn't work.

Winsock Send Data Help
hi all
i have an application using winsock for email purpose
now if i need to send a single mail to multiple users then
i m seperating these numbers and attaching them with the data individually
i store them in the client database
and then after checking the server connection state i send them one by one
say msg1:number1 then msg1:number2 and so on
but i get some processing error at the server
so my question is where shud the delay be introduced at the server end or at the client end??
Samir

Samir
Skill is successfully walking a tightrope over Niagara Falls. Intelligence is not trying.

Winsock Send Data
I need to come up with a method of sending data in my turn based game. I'm a noob to winsock but I have the connection stuff down and get sending text but I need to make sure when I send other types of data I come up with a way of doing it that will work.

I've looked around a lot and gotten some useful info but I'm having trouble with the very basics of sending data/receiving it.

I am using a central server and multiple clients, where a client sends info to the server and it is then sent to either multiple clients or a single.

Anyway, how might I send say a boolean from a client to the server and back to a single client?

Like OnlineGame(ArrayNumber) = true for example?

Do I make up an arbitrary string like StrExample = "Test" if OnlineGame = true? And then send the info to the server? Like Winsock.SendData StrExample and then receive it on server with DataArrival? And use SelectCase StrExample = "Test" then OnlineGame = true? And then pass it on in same way to Client?

I need some kind of working sample. I see all the Splitting and packet delimeters and DoEvents and I get what they do but I can't put it all together for my game and what I'm trying to do for my specific game.

Any help would be appreciated. Thanks.

Winsock Data Send To Fast??
hi There,

First off i would like to say i'm pretty experienced in winsock, what with pop3, smtp chat programs etc under my belt. But i have a strange problem or a really annoying one at that,


-- Note --

I'm running 2 clients and a server all is work well, until this happens.

I'm sending 2 bits of data to the client(enable a button and cards update) one after the other and it gets added to the end of the string of the data arrival event.

here's what happens "Y$V^B%" --plus the data-- "$E(N)D" "J$V^B%" "$E(N)D"

as you can see it gets added to the end of the "Y$V^B%" so the case statement for that does not fire.

I originally used a Static variable and deleted this when each case statement has finished. but again this is no good because of the possibily of data arriving again before the code in the case statement has finished.

there must be a way to keep each block of desired data seperate and just delete that e.g

(1) "Y$V^B%" --plus the data-- "$E(N)D"
(2) "J$V^B%" "$E(N)D"

I suppose i want it to behave like a stack!! I though of this way:

Make a Thread!! yes they are unpredictable.

The thread should running concurrently(All the time).

keep the static variable but have its arrayed, each block of data goes in each array segment.

the thread would parase each array segment and do it s think!!

then i would have to work a way of deleting that segment(quickly) Copymemory!!

if anybody has other ideas please can you help.

the pig..

Winsock Errors During Data Send
I am unable to figure out what is going on with a winsock control.

Here is what I am doing...

On the server side, the Winsock_ConnectionRequest happens

<code>
Private Sub Winsock_ConnectionRequest(ByVal requestID As Long)

If Winsock.state <> sckClosed Then Winsock.Close
Winsock.Accept requestID

End Sub
</code>


Winsock_DataArrival happens and the server receives a Cr Lf delimited text stream

<code>
Private Sub Winsock_DataArrival(ByVal bytesTotal As Long)

Dim str_ItemData As String
Static str_buffer As String
Dim int_packetlen As Integer

Winsock.GetData str_ItemData, vbString

str_buffer = str_buffer & str_ItemData 'First put the text into a buffer
int_packetlen = InStr(str_buffer, Chr(&HA)) 'Take the first chunk of text up to the Cr
If int_packetlen > 0 Then
BunchOfSTuffRoutine (Left(str_buffer, int_packetlen)) 'Then do a bunch of stuff with it
str_buffer = Mid(str_buffer, int_packetlen + 1) 'Now work with the next chunk of the text stream
End If
End Sub
</code>

Ultimately, I end up with;

error 10053, Connection aborted due to time out or other failure.
error 40006, Wrong protocol or connection state for the requested transaction or request

Both errors occurs during the data send portion... or at least when I hit the 'debug' choice on the msgbox, this is where it goes...

<code>
Private Sub MyTextbox_Change()

Winsock.SendData Trim(MyTextbox)

End Sub
</code>


The client in this case is first sending a connectivity test to the server which consists of a logon and a few routines that are done by the BunchOfSTuffRoutine listed above. This all works fine the first time, that is, both the server and the client do what needs to be done with the data, and the client receives the data returned by the server. However, if I send the connectivity test again, or send more data from the cient, the error occurs.

Thank you for any help...

Winsock Send Data Problem
I have two Winsock Controls on my form. One is a listener, and the other is used to activate the "DataArrival" subroutine. In this subroutine, I call a processing subroutine. After my processing is complete, I'd like to send a message back to the RemoteHost who sent the original request. How can I capture the RemoteHost name so that I can use "SendData" to send a confirmation message back to the sender? Thanks in advance for your help.

Edit: Please start posting your threads in the proper forum. Thanks.

Winsock Data Send Problems
okay i have a winsock client/data connection that is okay but i think im sending to much data to fast. if im sending some data i place a 4 digit key code infront of it for expample:

winsock.send data "0001" & text1.text



now my program is sending 40 requests at one time, cause its a game and it has to load about 40 things to the server when you connect so when you connect the server sends a request for the update and then the client sends 40 seperate data sends to the server, my code looks something like this


winsock.send data "0001" & text1.text :Doevents
winsock.send data "0002" & text2.text:Doevents
winsock.send data "0003" & text3.text:Doevents

all the way to "0039"


this is what i thought was going to happen:

the server recieves first data sent then i


Winsock_DataArrival(Index As Integer)

Winsock(Index).GetData strData


strCode = Mid(strData, 1, 4)


Select Case strCode

Case "0001" '
all someEvent(Mid(strData, 5))





but when the 40 diffrent data sends go through, they all go at one time so i get a sring that looks like

"0001text10002text20003text3"... and so on all the way to 40, what can i do to send the data one at a time


thank you for all your help, ive been up for 13 hours straight trying to figure this out, im just getting new to winsock, all my other apps are single computer

thanks for your time for reading, all replys are welcomed

Winsock Send Data Result Into ????
Hi there,
I got a server and client created into VB6.
In the server I got this:

Code:
sAccept(aFreeSocket).SendData "/connect>1"

And in the client,

Code:
Dim Data, Temp
sClient.GetData Data

But, in the client when I do Debug.Print Data, it gives me this: "?????"

Does someone got a clue on this?

How To Send POST Data With Winsock In VB
I am trying to send POST data with Microsoft Winsock control but keep on receiving garbage from the webserver. Can anyone tell me the reason please?

What I send:

POST /search HTTP/1.1
Host: www.google.com
Content-Length: 30
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Media Center PC 3.0; .NET CLR 1.0.3705; .NET CLR 1.1.4322)
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
Connection: close

hl=en&q=sql+tutorial&btnG=Google+Search

What I get:

HTTP/1.1 501 Not Implemented
Connection: close
Content-Type: text/html
Server: GWS/2.1
Transfer-Encoding: chunked
Content-Encoding: gzip
Date: Mon, 23 Oct 2006 17:08:55 GMT
Cache-Control: private, x-gzip-ok=""

Problem With Winsock Send Data
I have a program in vb6 that sends data to a server using winsock. The problem that I am having is everytime when I use the winsock.SendData and winsock.Close only winsock.Close get executed or run not the SendData. Is there a way to use both of those at the same time? Like:


VB Code:
winsock.SendData myStringDatawinsock.Close


I tried looping one of the winsock control for a few seconds and doesn't work.

Example:


VB Code:
Dim intTime as IntegerDim SendComplete as Boolean SendComplete = FalseintTime = 0 Do While intTime < 3600    If SendComplete = False Then        winsock.SendData myStringData    End IfLoop


Any suggestions and help would be greatly appretiated, thanks in advance.

Winsock Does Not Send Data Sometimes!? [GURUS Please Help]
I found a problem while i was trying to build a irc client. It's a normal client without many code by now but the thing is that after the client play the ping-pong it doesn't send correctly data.

Is there any reason to this happen?


VB Code:
'Play ping pong with the server    If Split(sRecv, " ")(0) = "PING" Then        sckIRC.SendData "PONG " & Split(sRecv, " ")(1)Debug.Print "PONG " & Split(sRecv, " ")(1)        GoTo theEnd    End If


After that, the first time i try to send data it won't send.
I already tryed to debug the application and seems to be everything correct and it should work.
I'm lost...i can't understand why is this happening. Anyone already had this same problem?

Winsock Send Array Data!!
how to send array using winsock?

Send Binary Data Winsock....
How can I send Binary Data with winsock and know when it is the end of the transmission from the client in the data_arrival event?????

THANK YOU!

Winsock Send Different Data To Different Clients
He everyone,

I want to send different data stored in sSend(i) to different clients. This means sSend(1) must be sent to the client connected on winsock(1) and wich IP has been stored (maybe needed?) in sRemoteHost(1)....

I can't figute out how to solve this one... Probably very simple... I can't find it with the search either so please help me out!

Thanx

Bloged

Winsock: Send Data Faster
Hey. I am using Winsock to send data. The only want I know how to send a multiple of data is do a loop. But in my loop, I have to pause 1 second before sending again r the data clumps together and it send strings as 1 when it is actually 2. This is slowing my app time down for my users. I am using this protocol: additem_m

Where item is the data being sent and the cleint handles the additem and does something with the item. Any help?

Winsock Is Connected But Can't Send Data???
Hail,

I have a server client app. Server app is on my cpu connected to the net through DSL, client is on my laptop connected through 56K account. Basically, I want to run both in debug mode to see what happens. Problem is although they are connected, when I use the senddata, nothing happens. It does not trigger the sendprogress event nor the sendcomplete event. In the meantime, the server also accepts the connection but does not receive any data (receivedata event not triggered). What bugs me the most is that I have no problem sending data when doing it with a friend (one has 56K connection and it works!) I guess my request is to know how it is possible to have a connection (winsock1.state = 7) but not be able to use senddata?

Phailak

Increse Data For Send By Winsock
Hi all,
 
     I have used winsock for communication between server and three clients, and i want to implement parallel program. So, when i sent data to client,,, i found difficults that the buffer limitted with size less than 4000 digits. I need to increase to send data with 10000 digits length.

If possible, i need some help.

thanks for you response.

best regards, Ehtiba

email me

Send Data To Browser With Winsock?
I am making a small server application for windows. I want to be able to send a image to the browser after a request has happend. I have made the server part, using winsock and listen commands. I know it would have something to do with senddata command, but I keep getting errors. Can anyone help, please. Source below.

Private Sub tcpServer_ConnectionRequest(Index As Integer, ByVal requestID As Long)
Dim a As String
Dim b As String
Dim c As String
Dim d As String

a = CStr(requestID)
b = CStr(Index)
c = "Hello" ' just testing text
d = tcpServer(Index).RemoteHostIP

If Index = 0 Then
intmax = intmax + 1
Load tcpServer(intmax)
tcpServer(intmax).LocalPort = 0
tcpServer(intmax).SendData (c) ' just testing text
End If
End Sub



skidz@syspac.com

Does Winsock Able To Send Binary Data Thru Internet?
Hello all pals!

I got a silly question to ask everyone. As i have read some example about sending file via winsock, I've found that before the data is sent, it must be hashed. So does winsock able to send binary data thru internet without hashing?

Easy Winsock TCP Data Send Command...
Hey,

I had this command working a few days ago. It's a really simple program. Thanks for the help!

This is my Server. The winsocks name is Winsock1 and it's index is 0.

VB Code:
Private Sub cmdSend_Click()       Winsock1(0).SendData txtChat.Text    DoEvents     'txtMain.Text = txtMain.Text & vbCrLf & txtChat.Text    txtChat.Text = ""End Sub



My client should recieve like this

VB Code:
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)Dim strData As String    Let txtMain.Text = ""     Winsock1.GetData strData

btw, thats not the whole client script, it is a bit of it. The client uses a winsock with the name of Winsock1

Ehh I'll just put the whole server code here, nothing private in it :P

VB Code:
Option Explicit   Private Sub cmdSend_Click()       Winsock1(0).SendData txtChat.Text    DoEvents     'txtMain.Text = txtMain.Text & vbCrLf & txtChat.Text    txtChat.Text = ""End Sub Private Sub Command1_Click()data.Text = ""End Sub Private Sub Command2_Click()    Load Form2    Form2.ShowEnd Sub Private Sub Form_Load()        Winsock1(0).LocalPort = 10101  'In my example winsock1(0) is the listening winsock... others are use for two way communication..    Winsock1(0).ListenEnd Sub Private Sub Winsock1_ConnectionRequest(Index As Integer, ByVal requestID As Long)Dim newIndex As IntegernewIndex = Winsock1.Count     'We have to get another socket to communicate with incoming client...Load Winsock1(newIndex)  'Loading into the arrayWinsock1(newIndex).LocalPort = Winsock1(newIndex).LocalPort + 1   'Set new local port, i.e. 1 plus previous portWinsock1(newIndex).Accept requestID    'Now accept the requestList1.AddItem Winsock1(newIndex).RemoteHostIP    'Adding to list to see the IP of incoming client.. End Sub Private Sub Winsock1_DataArrival(Index As Integer, ByVal bytesTotal As Long)Dim strData As String    Winsock1(Index).GetData strData    data.Text = data.Text & strDataEnd Sub


Anyone know what this little bug can be? I don't wanna change any of the code except the

VB Code:
Winsock1(0).SendData txtChat.Text


That has got to go!

Thanks!

How Can You Use Winsock To Send Data That U Get From Port Sniffers?
Code:
0000: 20 53 52 43 00 00 44 45 53 54 00 00 08 00 45 00 SRC..DEST....E.
0010: 00 4A CC 04 40 00 80 06 BD 17 CB 5E EA D9 D8 88 .J..@......^....
0020: E2 D0 04 8B 00 50 00 71 FD 88 82 BE 3A C0 50 18 .....P.q....:.P.
0030: 21 80 7F 04 00 00 59 4D 53 47 0A 00 00 00 00 0E !.....YMSG......
0040: 00 57 00 00 00 00 00 00 00 00 31 C0 80 73 75 6E .W........1..sun
0050: 64 61 44 67 69 61 C0 80 dxxxa..

how can you send that in winsock?

Trying To Send Data Using Winsock Prior To Form_Unload
When the form unloads I need it to send data via winsock. It seems the form unloads before that process is complete.

I have tried using Form_unload and Form_QueryUnload

I appreciate any help.

Here is the code:

Option Explicit
Private strAction As Integer
Private strName As String
Private strIP As String

Private Sub Form_Load()

'Specify Port
sckIOClient.RemotePort = 100

'specify Host ID
sckIOClient.RemoteHost = "147.56.170.29"

'strAction determines action. 1 is login, 2 is active, 3 is logout
strAction = 1

'Determine Login ID from Registry
strName = GetString(HKEY_LOCAL_MACHINE, "NetworkLogon", "UserName")

'Determine Local IP Address
strIP = sckIOClient.LocalIP

sckIOClient.Connect

End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

'strAction determines action. 1 is login, 2 is active, 3 is logout
strAction = 3

sckIOClient.Connect

End Sub

Private Sub sckIOClient_Connect()
Dim strData As String

'Build String
strData = strAction & "," & strName & "," & strIP

'SendData
sckIOClient.SendData strData

End Sub

Private Sub sckIOClient_SendComplete()

sckIOClient.Close

End Sub

I Need To Send Alot Of Data Through Winsock With Multiple Connections
im doing a testing client/server program which basically for an assignment at my highschool. the servers reads the questions for a test from an ini file and then when the user connects to the server using the client, it sends a request for the first test question ( the test is multiple choice. when the user have answered all 20 questions the test is finished and sends a msg to the server to say the user has finished and the client sends the users answers and the server cuts off that client connection and blocks any reconnection attempt. How can i do this?? has anyone got any ideas??

thanks, dan

Using Winsock Or Soemthing To Send Data To Antoehr Computer?
is that what winsock is for? if so, how would I set it up so that i can, say, send a line of text to one of my friends when i click a button?

Using Winsock For Multiple Connections To Send Lots Of Data
im doing a testing client/server program which basically for an assignment at my highschool. the servers reads the questions for a test from an ini file and then when the user connects to the server using the client, it sends a request for the first test question ( the test is multiple choice. when the user have answered all 20 questions the test is finished and sends a msg to the server to say the user has finished and the client sends the users answers and the server cuts off that client connection and blocks any reconnection attempt. How can i do this?? has anyone got any ideas??

thanks, dan

Winsock Send Data To Remote Host In Activex Dll
Hi..

I need to send data to a remote host (in a certain port) by using winsock.. but I want to create the VB code in ActiveX dll because I need to call this function from ASP.. so, the client will only see the asp page only..

just say that the data I want to send is "1234567" to server "www.test.com" in port 4000.

Anybody can suggest a solution?

Thankssss

Winsock Send Data To Remote Host In Activex Dll
Hi..

I need to send data to a remote host (in a certain port) by using winsock.. but I want to create the VB code in ActiveX dll because I need to call this function from ASP.. so, the client will only see the asp page only..

just say that the data I want to send is "1234567" to server "www.test.com" in port 4000.

Anybody can suggest a solution?

Thankssss

Convert An Online Form To WinSock Data Send Ad Submit
I have asked a similer question but i was a lil ahead of myself!, i was discussing Send Methods, but i need to crawl before i walk n run

I need to go back to step one

I have an Online Form, I want to Fill the form the in and submit it VIA winsock, a similer example of what i want to do would be an Account Auto Sign Up for say GEOCITIEs..

This isnt for a geocities sign up program heh, that was just an example so u can see what i need to do, i need to convert anything the size of geocities...

My Form has 4 Elements, 3 Text Boxes called Name, Email, Message and 1 Submit Button!

<form action= "add.pl" name="add" method="post">
<input name="name" maxlength="24" size="30" value="">
<input name="email" maxlength="24" size="30" value="">
<input name="message" maxlength="128" size="50" value="">
</form>

How would i send this data my server using winsock ?

Help {Winsock Data To Listview Control}
How can i add the data that send by the server to client intolistview? In listview i have to columnheader cald "First Name" and "Last Name". Just i want to Split the "," then the output in listview should be like this:

Code:
Firstname Lastname
Name1 Lastname1
Name2 Lastname2
Name3 Lastname3

right now i have this code:

server:

Code:
DO while rs.EOF = false
Winsock1(Index).SendData "rs" & "~~" & rs.Fields("FirstName") & "," rs.Fields("LastName")
loop

Client:

Code:
if Mid(data, 1, 2) = "rs" then
for i - 1 To 1
wak = Mid(data,5)
if Len(wak) Then Listview1.Listitems.add , , wak
Nex i
exit sub
end if
end sub

Any Idea? pls helpme.. thanks in advance.

Receiving Data Using The Winsock Control
Hi people,

I have 2 programs, one in php and one in VB. the idea is that when someone goes to the php script, it sends the data to the vb script, which pops up an alert saying someone has come to the sight.

here is the php

PHP Code:





<?php
$fp = fsockopen("xxx.xxx.xxx.xxx", 9999, $errno, $errstr, 30);
if (!$fp) {
   echo "$errstr ($errno)<br />
";
} else {
   $out = "reading";
    if (fputs($fp, $out)){
       echo "done";
   }else{
       echo "failed";
   }
   
   fclose($fp);
}
?>






now, when this is run. i get "done" output on the screen.

here is the VB


Code:


Private Sub Form_Load()
Winsock1.LocalPort = 9999
Winsock1.Listen
Label1.Caption = "listening"
End Sub

Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
Label2.Caption = "connection requested"
If Winsock1.State <> sckClosed Then _
Winsock1.Close
' Accept the request with the requestID
' parameter.
Winsock1.Accept requestID

End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
Winsock1.GetData (strData)
Label2.Caption = "received:"
Label3.Caption = strData
If strData = "reading" Then
MsgBox "reading requested"
Else
MsgBox "Reading failed"
End If
Winsock1.Close
End Sub

Private Sub Winsock1_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)
Label2.Caption = "error"
End Sub



Now, when the php is run. the connection is all made and all is good. however, the data that should be sent is "reading" so the alert "reading requested" should appear, but i get the "reading failed" alert.

I have set the control label3 to output the data that is received, but it is blank so it is making the connection, but receiving a blank string.

Also, if i run the script again, i get, cannot connect to xxx.xxx.xxx.xxx, connection refused

Sending Data With Winsock Control
Can I send another data type than String with winsock control?
I want to send Type Variable, or Class object.
can it be done?

Interrupting The Sending Of Data Through Winsock Control
I was wondering if there was a way to interrupt the sending of data through a winsock control. I have an app that can send emails through the winsock control, however I also want to implement a cancel button if the user decides not to send the e-mail during transmission. I tried to
make a button that when clicked would attempt to
close the winsock connection. The problem is that
it waits for the data being sent before closing the connection. Is there any way I can directly interrupt the connection when the button is clicked. Any help would be greatly appreciated.
Thanks

Can I Use A Winsock Control But Not Use The Data Arrival Events?
Hello,
I have sample winsock code here to handel on data arrival events.. is it possible to not handle this handler and just read the tcp/ip buffer of a cycle instead??

also is it possible to declare a winsock control in a .cls instead of putting one on a form? so that way each instance of the .cls will have its own winsock control!


Thanks!

Sending Binary Data Through The Winsock Control
I'm probably missing some little spec setting to the send or getdata methods of the winsock control, but all I am able to send is text. How would I go about sending somethin binary? (i.e. graphics, mp3, mdb)

Receive Data In Winsock Control In Packets To Be Put In Arrays
Hello all,
I have a C program running on a Linux server which is sending data from an array of Structures of size 40 (in a concatenated string).I have calculated that each array needs 300 char size so 12000 chars must be sent in total.
The problem is that the VB client program using a Winsock control is not able to receive the 12000 chars (11.7 KB) with a single receive in the DataArrival event, using the .GetData property. It receives a string of 600 chars (2 arrays of the structure) with no problems. (I have not tested the max limit but 12000 is the target.)
Is there any solution to receive the data in parts and put in 40 arrays in the client side ? Is the use of loops or a control array of Winsock Controls a solution ? If yes, how ?

I would appreciate any help.
Thank You.

Data Is Lost In File Download Using FTP/Winsock Control
I'm using Winsock control and the FTP to download file from a server. Now my problem is, I can't keep a consistent file download (with the same file!). Sometimes, I can download the whole file size, sometimes I can't. I figured fast connection can result to data "lost" - that is, my code most probably wasn't able to capture ALL the data received.

So this is my question, how can you ensure that ALL data shall be received and stored into the local file?

Do look at my current code (I only included this single procedure cuz I take it the answer to the problem lies in here.):

+++++++++++++++++++++++++++++++++++++++++++++++++++++

Private Sub wscClient_DataArrival(ByVal bytesTotal As Long)
Dim sTmp As String

Do Until wscClient.State = sckConnected
DoEvents
Loop

'save to local file
wscClient.GetData sTmp, , bytesTotal
Open gstrFileName For Binary As #1
Put #1, lngByteSent, sTmp
lngByteSent = Seek(1)
Close #1
lngProgress = lngByteSent

'file complete
If (lngProgress = lngTotalByte) Then
MsgBox "File Transfer finished. You may now proceed.", vbOKOnly, "Download Files"
wscClient.Close
End If

End Sub
+++++++++++++++++++++++++++++++++++++++++++++++++++++

Embedded Winsock Control In Dll, Called From VBA Application Not Receiving Data
I've got a really bizarre problem that I hope somebody can help me with. I'm writing an ActiveX dll that encapsulates a Winsock control on an empty form and provides some custom methods to interact with a server. The desired end result is that this dll will be importable into a VBA excel application handle the necessary communication tasks so that all the VBA application programmer has to do is perform function calls to read/write/connect/etc... from the server. I've had much success getting this to work upto a certain point. I have great one way communication from the VBA app to the server, but the data from the server is never received, instead my methods timeout. I know it is not a server problem because I've been testing this dll and server on a VB6 machine, and everything works great, so its something strange about the VBA environment. Now for the really weird part. If I step through my code, the data from the server is received fine. Sounding like a timing problem, I added delay loops in certain places, but still my methods timeout. However, placing MsgBox's in the application code instead of delay loops, and the data is received fine. My theory is this: The embedded winsock control is trying to fire the DataArrival event in the dll, which stores the data to a private data member. I then use a read method to read from that variable. For some reason, the execution of the VBA application is preventing this method from firing. Further more, I created I method that doesn't wait for the event to fire, it manually uses the GetData method, but still not data is returned. Therefore, the application is not only preventing the event from firing, its preventing the data being passed from the port to the Winsock control. By generating a msgbox, enough windows messaging is occuring that this data is being handled correctly and loaded into my variable. I've already tried playing DoEvents statements in various parts of my code, but did not help.

Any ideas what's going on or how to fix it?

WinSock &lt; Send A Reply To A &"Data Transfer&"?
Hey ya PPL:

How do i return a connection string (My Connection is still active) via WinSock?

(All my code so far):

[Client]

VB Code:
Private Sub cmdLogin_Click() If Winsock1.State <> sckClosed Then Winsock1.Close Winsock1.RemotePort = cboPort.TextWinsock1.RemoteHost = cboHostName.Text Winsock1.Connect ' Try and Connect to the IM ServerDo Until Winsock1.State = sckConnected    DoEvents: DoEvents: DoEvents: DoEvents    If Winsock1.State = sckError Then        MsgBox "There was a problem connecting to the IM Server!" & vbCrLf & "Please try again later!", vbOKOnly, "Connection Error"        Exit Sub    End IfLoop ' Send the Data: Tell the server this is a Login Request, Your Username, And PasswordWinsock1.SendData ("cmdLogin" & " : " & txtUsername.Text & " : " & txtPassword.Text) End Sub Private Sub Form_Load()Dim port As Integer ' Set the Caption to the App Title & Form TitleMe.Caption = App.Title & " - Login" ' Add host names to the cboHostNamecboHostName.AddItem "127.0.0.1"cboHostName.AddItem "realm-ed.co.uk"cboHostName.AddItem "thewalks.ods.org" ' Add the Connection Ports to allow the user to' Choose different serversport = 6660Do Until port = 6671cboPort.AddItem portport = port + 1Loop ' Select the First Item in the list' Using DropDown List style Combo'scboHostName.ListIndex = 0cboPort.ListIndex = 0 End Sub Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)Dim strReply As String     Winsock1.GetData (strReply)           MsgBox strReply End Sub


[module in client - Has a msgbox etc for input errors]


==

[Server]

VB Code:
Dim intMax As Integer Private Sub Form_Load()lstLogWindow.AddItem Now & " : Loading Server"Me.Winsock1(0).LocalPort = GetSetting(App.EXEName, "Options", "Port", "6668")Winsock1(0).ListenlstLogWindow.AddItem Now & " : Listening on Port " & Winsock1(0).LocalPortEnd Sub Private Sub Form_Resize()On Error Resume NextStatusBar.Top = Me.Height - 945StatusBar.Width = Me.Width - 120frameWindow.Height = Me.Height - (795 + StatusBar.Height)frameWindow.Width = Me.Width - 240lstLogWindow.Height = Me.Height - 1250lstLogWindow.Width = Me.Width - 500End Sub Private Sub Winsock1_Close(Index As Integer)    Winsock1(Index).Close    lstLogWindow.AddItem Now & " : Connection Closed For: " & Winsock1(Index).RemoteHostIPEnd Sub Private Sub Winsock1_ConnectionRequest(Index As Integer, ByVal requestID As Long)    If Index = 0 Then        intMax = intMax + 1                ' Load a new socket for this user        Load Winsock1(intMax)        Winsock1(intMax).LocalPort = 0        Winsock1(intMax).Accept requestID                lstLogWindow.AddItem Now & " : Connection Request From: " & Winsock1(intMax).RemoteHostIP    End IfEnd Sub Private Sub Winsock1_DataArrival(Index As Integer, ByVal bytesTotal As Long)Dim strIncoming As String, Result As StringDim sString As String, MyArray() As String     Winsock1(Index).GetData strIncoming    MyArray = Split(strIncoming, " : ")lstLogWindow.AddItem vbTab & vbTab & MyArray(0) & " For User: """ & MyArray(1) & """ Encrypted Password: """ & MyArray(2) & """"lstLogWindow.AddItem vbTab & vbTab & "Checking Login"     Call Check_Login(MyArray(1), MyArray(2), Me.lstLogWindow)     Winsock1(Index).SendData Result    End Sub


[Module in Server:]

VB Code:
Public Sub Check_Login(User As String, Password As String, lstLog As ListBox) Dim Result As String     Result = "Correct.Login.-.Continue."    lstLog.AddItem "Login Success"End Sub

(Note its only a temp login module )

But, It never sends a Reply?

How do i get it to send a reply?

I created a Control Index for the Winsock on the server?

If any one knows my problem, Please help

Winsock - Send PictureBox Contents Thrue Winsock?
Hey all, is it possible to send the contents of a PictureBox thrue a Winsock?

I know i can save the contents first to file and then send as file, but wondering this is possible, the purpose is in my chat project i have a webcam capture feature wich works fine, but i can't figure out how i can send this stream, did some searches but not found any results about it.

=============================================
aka Red2048.

How To Send Multiple To Multiple Data Using Winsock
I have two forms client and server i run in a localhost. I want to send multiple data from client and server. but how?

My program is too big and long so I make a simple same example to you

Lets say I got String a,b,c i want to send a,b,c to the server and stored in String sa, sb,sc in the server form then send ack(acknowladgement) back to the client...ask client to send the different new data back to the server again but....the data in the server get corrupted in second time ...means it only accept b and c...it ignore the a why?

please help thanks

Code:dim a,b,c,ack as string ' in global

privete sub command_send click
a="qwe"
b="qwe"
c="qwe"
tcpclient.senddata(a)
tcpclient.senddata(b)
tcpclient.senddata(c)
end sub

dim sa,sb,sc.ack as string 'in global also

Private Sub tcpserver_DataArrival(ByVal bytesTotal As Long)
call tcpclient.getdata(sa,8,3)
call tcpclient.getdata(sb,8,3)
call tcpclient.getdata(sc,8,3)
text1.text= a & b & c
ack="received"
tcpclient.senddata(ack)
end sub

Private Sub tcpclient_DataArrival(ByVal bytesTotal As Long)
call tcpclient.getdata(ack)
a="xcx"
b="xcx"
c="xcx"
tcpclient.senddata(a)
tcpclient.senddata(b)
tcpclient.senddata(c)
end sub

Getting Data As Hash Table In Winsock Data Arrival
Hello Gurus,

I need a great help from u all Ppls.

The task is, a Server application(Developed in Java) is running in a system. Which would send data to its all client.

Now my problem is I am connecting the Server from my vb program using Winsock Control. No problem, My application is getting coneected. The problem here now is the Java Server Application is sending the data as Hash Table.

I am getting some data in DataArrival event when I try to get the data as follows

Winsock1.GetData str_data, vbString
Debug.print str_data

But here I am getting the raw data I think which is as follows

’ yyyyyyyyyyyy
yyyyyyyyyyyyyyyyyyyyyyyy
yyyyyyyyyyyyyyyyyyyyyyyy
yyyyyyyyyyyyyyyyyyyyyyyyy
yyyyyyyyyyyyyyyy

How could I get those Hash Table's data in my Winsock DataArrival event.

Pls Help me gurus

V.P. Vijayavel

Send A .JPG File Using WinSock Control
Hello all

Since this is my first post in the forum I hope that I am in the right category.

I am using the WinSock control in VB6 to design a server-client environment where the server must send jpg pictures to the client. In the past I designed a TCP chat server, however I noticed that sending pictures is different (at least for my programming level). Unmfortunately I do not have any code to submit in order to correct me.

I would be grateful to anyone that could give an idea to implement this task.

Thank you in advance

KostasP.

Send XML As String Using Winsock Control
First of all i would like to make clear that I am a newbie in programming.So be gentle :P

The problem is the following. I've created 2 programs that communicate with each other over TCP using XML files. The XML files are generic and they are modified during runtime. the thing is that the SendData() function of the winsock control doesn't accept my XML files as an input. I am using MSXML4 SDK2 so I know that I can convert the xml file to string using the .xml to make things simpler here follows some code describing what I've done:

Dim DomXML As MSXML2.DomDocument40
Dim XMLelem As MSXML2.IXMLElement

Set DomXML = New MSXML2.DomDocument40
Set DomXML.setProperty "SelectionLanguage", "XPath"
DomXML.load("command.xml")
Set XMLelem = DomXML.selectSingleNode("//command")
XMLelem.Text = "HI"
Winsock1.SendData(DomXML.xml)

The command.xml file is the following:

<xml>
<command />
</xml>

The thing here is that if I use a MsgBox to see the string returned in DomXML.xml I get sth like that
<xml>
<command>HI</command>
</xml>
which is exactly what I need to send.Still I can't get SendData function send it.
I would appreciate it if one could help me with it.

Copyright © 2005-08 www.BigResource.com, All rights reserved