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




Sending Multiple Values Through Winsock??


Through my searching into the tutorials and programs on the internet, i noticed that all examples concerning WINSOCK (in visual basic 6) talks about sending one value from client to server.

I wonder if there is a way to send multiple values , coz i have the following task:

I have 3 text boxes in the Client program , using winsock , i want to send these 3 values to another 3 text boxes in the Server program with just one click of "Send" button.

if any body can help with the code i will be grateful




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Sending Values Multiple Values To ONE Word File[Resolved Like A Horny Ho']
I have searched for how to do this and have the code to start up a word app: (thanks to Carl)

Option Explicit

VB Code:
Private Sub Command1_Click()    Dim WordApp As Word.Application    Set WordApp = New Word.Application    With WordApp        'create word app from default template        .Documents.Add "Normal.dot"        'don't ask me to save before quiting!        .DisplayAlerts = wdAlertsNone        'show the word window        .Visible = True        'active the window        .Activate        'send text to the window        .Selection.Text = "Hello World!"        'print the page        .PrintOut        'wait for document to print before quiting        Do While WordApp.BackgroundPrintingStatus        Loop        'quit        .Quit    End With    Set WordApp = Nothing    End Sub


But what I need to do is have users check the fields who's values they want to include in a report and have the word file as the report. Here's a GIF of what I mean:

The checkboxes indicate the values and field names to be included in the word document.
Does anyone know how to do this/a tutorial for this?
thank you xxxx

Winsock - Sending Multiple Strings
my app seems to be sending two seperate strings as one string and i can see why .... here is the code :


Code:
Private Sub Winsock_ConnectionRequest(ByVal RequestID As Long)
Winsock.Close
Winsock.Accept RequestID
Winsock.SendData Text1.Text 'sends a name
DoEvents

RandomPlayer 'public sub that generates a random number 1 or 2

If Text2.Text = "1" Then
Option1.Value = True
Option2.Value = False
Winsock.SendData "play1"
DoEvents
Else
If Text2.Text = "2" Then
Option1.Value = False
Option2.Value = True
Winsock.SendData "play2"
DoEvents
Else
End If
End If
End Sub

so when the name appears in the other app it appears as something like:
NAMEplay1

can anyone help me?

Phear

P.S how comes the VB tags dont work no more :/
P.S.S i dont wanna be sad but I preferd the old look i think :/

Usin Winsock Sending And Receiving Over Multiple Forms
Using 2 forms (one to conenct host and client and one for the actual game), I tried to receive integer data with the:


Code:
winsock.getdata intOnline

then i tried to put the form with winsock in there:


Code:
frmConnection.winsock.getdata intOnline
but it still wouldnt work, is there something i have to do?

Getting Header And Sending Data Through Multiple Sockets With Winsock
Hi everyone, I am looking to open up multiple winsock connections and send data to a web server.

I am only familiar with Inet and winsock seems complicated. Can anyone instrict me on how to get started? Also, i need help getting the header of a server. Thanks!

~Tw1nChromeGlocks

Winsock - Sending Messages From Server To Multiple Clients.
HI,

I have set up a client and server app so that many instances of client can connect to the server and send messages at the same time using Index.
However,

I want to send messages from server to client also - how can i do this since I get error message "Invalid operation in current state" when I try to connect from server to client - i need to get Winsock(0).State = connected and can't - do i need to name Winsock differently between 2 applications. I looked at www.winsockvb.com but can't find an answer to my problem.
Any guidance would be greatly appreciated!! Thanks!

- Sending Data To Multiple Clients Via Winsock- Same 40006 Error.
trying to send data to multiple clients, but keep getting same error - 40006: Wrong protocol or connection state for the requested transaction or request.

The first send works fine- always throws error on 2nd recipient. Nothing wrong in sending just one request to that client.

2 Winsocks, not indexed - vb6
Code:

Code:
                        'SEND TO FIRST
                        With frmWinsocks.Winsock5
                            .Connect 192.1.1.111, 1007
                            .SendData "data"
                            DoEvents
                            Call frmWinsocks.SafeCloseAfter 'CLOSES CONNECTION
                            DoEvents
                        End With
                
                        'SEND TO 2ND
                        With frmWinsocks.Winsock6
                            .Connect 192.2.2.222, 1008
                            DoEvents
                            .SendData "data 2" '<-ERROR HERE - error #40006 - the state is 6 (connecting), but shouldn't be
                            DoEvents
                            Call frmWinsocks.SafeCloseAfter6 CLOSES CONNECTION
                            DoEvents
                        End With





ARE THERE ANY ADVANCED WINSOCK CONTROLS OUT THERE? SOMETHING WITH ERROR CHECKING AND MULTIUSER SERVER/CLIENTS?



Edited by - pbeast on 2/3/2007 2:58:25 AM

Updating Multiple Records Using Single Field Multiple Values..
dear

i have a flex in whcih i am displaying records.

lets say there are 5 records in the flex, with srno 1, 2, 3, 4, 5 and out of these 5 records i want to update 3 records srno 1, 3, 5.

srno date

1 01/12/2005
2 02/12/2005
3 10/12/2005
4 10/12/2005
5 11/12/2005

Like in delete statement we use this syntax.

delete * from tablename where fieldname in ("fieldvalue")

can we use the same concept for updating single field date in my case

can we use update like given below

update tablename set date = " & "'" & Format(Date, "dd-MM-yyyy") & "'" & " where srno in ("1,3,5")

But even after using the above syntax my data is not updated and also im not getting any error msg

hope to get helpful replies

regards

ladoo

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

Sending Hex Values
Hi ,

I am trying to send Hex values to the Com port
I don't know whether this is the Right way to send...
The Code is

Code:
Dim strhex
strhex = Hex(49) & "-" & Hex(33) & "-" & Hex(5)
MSComm1.Output = strhex


The string that I want to send is
1!05
since 49 is the Decimal value for 1
33 is the decimal value for !
5 is the decimal value for ENQ (according to the Ascii table given below)

The problem is i'm not receiving any acknowlegment in the com port..

please suggest !!!!

Sending Hex Values Mscomm
Before you say go and search, let me say i already have.

Situation:
My program needs to send hex values to a micro controllerthe micro controller will then carryout a fuction depending the sent sent value. I have a list of commands in Hex so i need to be able to send the data in a Hex form
(i know its gonna get converted into binary when its sent over the serial cable)

Problem:
[example i need to send value "0xF5"
how do i send the hex i realize i can send HEX vales using

MSComm1.Output = Chr$(&HF5)

But after searching i notice that it sugested to use a byte arrays. After thinking for a while i figured using a Byte Array would make more sence because there are times i need to send more than one byte of Hex values for a specific command

[example i need to send values "0xF5" 0xA1" "0xF8"]

i figured if i use a Byte array i could store all 3 values in a byte array and send that array making the code alot cleaner.(i am assuming that a byte Array holds a series of bytes)

the real problem is that am not sure how to declare a byte array, assign bytes to the array and the syntax for sending the array using mscomm.


also i would like to have a little understanding on how you let the compiler know what form the data your sending is in.
Text
Numbers
ASCII
Hex
Binary


Thanks in advance

Sending Values To Excel From VB6 (NOT VBA)
I wrote a program in VB6 and now I am trying to save those values to a sheet in an excel document that is allready created. I know how to import values into an excel sheet using VBA, but it would be more streamline if I could open the excel sheet from my VB6 program and paste the values in the correct location from there. I guess I just need a jump start, place to find information, or a simple example of this. Any help would be greatful, thanks!:

Sending HEX Values In MSComm
I am trying to interface to some external devices through my serial port. I need to send out some commands in hex, but I can't seem to do it. I also need to recieve back hex characters up to 64 bytes. I am in desperate need for help.

Also, I know that I can't open multiple ports simultaneously with the MSComm control. Has anyone ever worked with the Sax Comm control or any other? Do they work well?

Thanks

Sending Values To ActiveX EXE
I'm having trouble tracking down an answer to this.
I have 2 projects. One is an activex EXE. The other is a standard EXE. I want to run the standard EXE, and have it spawn an instance of the activeX EXE as a separate thread. I know how to add the reference to the ActiveX Exe, etc., but, when I spawn it, I want to pass it a chunk of data - actually a bunch of variables, maybe a user-defined type, which it will use as it runs in its own process.
Q. How do I do this?
I feel like I'm just missing something here. Any help is appreciated. The MS documentation doesn't seem to include this.
Thanks!

Sending Values To Outlook Express
Hi, I am trying to send out a mail with vb. I have the required To, Cc , Bcc and Attachment File Location in textboxes and want these to be transferred to a new mail message when i click a button, How do i code for this. Thanks.

Sending Values To My App From The Command Line.
I have read a few posts here about this... But.....

Basically, I have built a few apps and I keep getting questions from people such as ...does this program have command line options. I think they want to be able to pass arguments in and have my app do a "batch". Ok....the app does this....it creates and image from a label. You just type in text in a textbox and the label is created in the app. You can then save the label as a bitmap. No biggy... The problem is that some folks want to load a list of text (for example, from a text file or just multiple text) and have the program do all of them at once. I know I can do this from within the app....but what about this command line stuff. I haven't done it before.

Is there a code sample?

Thanks!

Sending Values To A Parameterized Query
Hi,

I have a data environment command object that has a parameterized query:


Select * From Transactions Where EmployeeID = ?


My form has a datagrid to be populated with the command object above.  How do I send the parameter value from the form?  Is it by one of the datagrid properties? Form properties?  Or by code?

Thanks in advance,
Ron


How The See The Values That You Are Sending Through Serial Port Of Your PC?
Hi every body,

I am trying to write a little program what would communicate with other devices using serial port. First of all, I have to make sure that the value (1, 0) that I intend to send to com port is really the (1, 0) value. How can I test that? That is how can I see the values that I intend to send to serial port? Thanks a lot for your help.

Regards,

Sending Checkbox Values && Dates To Access DB
Hi there

At runtime the user checks either one of two checkboxes. One saying YES, implying the user had changed their brake rotors, and one saying NO, implying they did not change their rotors. They enter a few other bits of information, such as current mileage, date, etc. that the maintenance was performed. When I the user hits OK to enter the information and send it to the DB, a datatype mismatch in criteria error comes up
The Code I was trying to use for this is included below:

Code:

If chkRotorsYes = True Then Rotors = True
If chkRotorsNo = True Then Rotors = False
Can I not simply just assign those True and False values to the variable and then send it to a Yes/No field in my DB?

Another Question I have is about the date.

Code:
strCurretDate = txtCurrentDate.Text
That is all the code I am using before it is sent to my DB. Do I need to format the strCurrentDate into shorttime to match the ShortTime field in my DB in order for this to work?

Possible?? - 2 Projects Sending Values To Same Textfile Or Excel Sheet
Hi,

I have 2 projects one with vb and the other a Word Document that are connected to each other. I have read about Group Projects. Would that be necessary in my case. If its complicated I'd rather not, but if its absolutely necessary for data transfer, I need help.

Well each student is to send values to one common textfile. At the moment I am only sending from vb. Is there a way to collect values from vb and Word. The program will run in the school server not on a stand alone PC??

Later I need to transfer the textfile to an Excel sheet. Maybe I thought there is a way to send data to an Excel sheet straight away?? I'm Not very experienced in vb I'm afraid. pls help me to go about it!! Thanks

Sending Function Values From Client To Server- Pls Guide
Hello Everybody:
I have created two Functions whose value I want to send from the client to the server. The Functions are defined as
follows:

Client Code
Function Parameter(ByVal name As String, ByVal value As String, ByVal remote As String) As String
Dim param As String
txtusername = name
txtValue = value
txtRemote = remote
param = name + " " + value + " " + remote

End Function

Function Variable(ByVal URL As String, ByVal TarFrame As String, ByVal ContactURL As String, ByVal ContactTarFrame As String) As String
Dim var As String
txtURL = URL
txtFrame = TarFrame
txtContactURL = ContactURL
txtContactTarFrame = ContactTarFrame
var = URL + " " + TarFrame + " " + ContactURL + " " + ContactTarFrame


End Function

Private Sub cmdSend_Click()
tcpClient.SendData Parameter(name, value, remote)
tcpClient.SendData Variable(URL, TarFrame, ContactURL, ContactTarFrame)

End Sub

Server Code :

Private Sub tcpServer_DataArrival(ByVal bytesTotal As Long)
Dim strData, strData1 As String
Parameter = strData

tcpServer.GetData strData
txtOutput.Text = strData
Variable = strData1
tcpServer.GetData strData1
txtOutput.Text = strData1
End Sub

When I run the code. I am not receiving parameter and Variable function values in txtOutput.Text..

Pls guide…

Rahil

Sending Keystrokes And String Values From A VB Program To A DOS P Rogram
I wish to send a value (string) from an Excel spreadsheet cell to a DOS
program.
Any idea how I might accomplish this?

Also, I find that the SendKeys command dosen't work in a DOS window, so I
need to come up with a way to send keystrokes programatically to the DOS
program. Any help?

I'm using VB 6.0.

Wayneth

Winsock Only Sending ????????
I wrote an internet chat program, and it was working fine...I was trimming up the code, but I didn't change anything....just removing redundant stuff....and making subs for frequently called code, however, now when I try to use it, the client and server will only send the ? character. Sometimes a 4 gets in there, and a >. (Even though neither was typed)

Anyone see this before?

Winsock Not Sending?
i have:

Client Side-

VB Code:
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)    Dim i As Long    Winsock1.GetData strIncoming       If strIncoming = ".badlogin" Then        MsgBox "The screen name or password you entered is not valid. ", vbOKOnly + vbCritical        If Winsock1.State <> sckClosed Then            Winsock1.Close        End If[color=Red]    ElseIf srtincoming = "SRY" Then        Form1.Show[/color]End IfEnd Sub


Server Side-

VB Code:
Private Function New_user(user As String, password1 As String, Index As Integer) On Error GoTo sry Dim rs As New ADODB.Recordset Dim rs2 As New ADODB.Recordset Dim conn As New ADODB.Connection Dim sConnString  As String sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=imdb.mdb" conn.Open sConnString    rs2.Open "INSERT INTO users ([username], [password]) VALUES('" + _            CStr(user) + "', '" + _            CStr(password1) + "') ", conn  [color=Red]sry:ServiceSocket(Index).SendData "SRY"[/color]Set rs = NothingSet conn = NothingEnd Function


sry: is to respond saying that the name is already taken. but my problem is, when i try to send the string "SRY" im not sure if it sends it back to the client because on the client side it doesnt show the form1 like id like it to

ne suggestions?

Winsock: Getting More Than I'm Sending
I have a file sending program and it appears for some reason that I'm getting more than I'm sending when sending a 2841675 byte file I receive 2844012 bytes. Is there some kind of EOF thing being sent at the end of the file?? if so how big is it?

Sending Hex Through Winsock
Does anyone know how to send "hex" through winsock? E.g. Something like...

Code:
HexData = 00 01 81 80 00 01 00 01 00 03 00 03 05 6C 6F 67
Winsock1.Senddata HexData

Or perhaps a function could help... such as...

Code:
Private Function EnHex(Hex as String)
'How could I code this?
End Function

Winsock1.Senddata EnHex("00 01 81 80 00 01 00 01 00 03 00 03 05 6C 6F 67")


Thanks. An example would be great.

Sending Multiple Attachments In Vba
im trying to send email to multiple ppls by using outlook and excel in vba
so far sending messages without attachments is working fine
but when i tried to send attachments using loops it failed
following is the source code...

Code:
Dim p As String
Dim s1 As String
Dim s2 As String
Dim s3 As String
Dim s4 As String
Dim i As Integer
Dim f As Integer
Dim appexls As Excel.Application
Dim myattachments As Outlook.Attachments

Private Sub Command1_Click()
start

For i = 2 To 1000
Dim mItem As MailItem
s1 = Worksheets("Sheet1").Cells(i, 1).Value
s2 = Worksheets("Sheet1").Cells(i, 2).Value
s3 = Worksheets("Sheet1").Cells(i, 3).Value
s4 = Worksheets("Sheet1").Cells(i, 4).Value
Text1.Text = Text1.Text + s1 + s2 + s3 + s4 + Str(i) + vbCrLf

If (s1 <> "") Then
myitem.To = s1
myitem.Subject = s2
myitem.Body = s3
Set myattachments = myitem.Attachments
myattachments.Add s4, olByValue, 1
myitem.Send
Set myattachments = Nothing
End If

If (s1 = "") Then
i = 1000
End If
s1 = ""
s2 = ""
s3 = ""
s4 = ""
Next i
End Sub

Private Sub Command2_Click()
ActiveWorkbook.Save
Workbooks.Close
End Sub

Sub start()
Workbooks.Open ("c:/sales.xls")
End Sub
so please help me..



Edit by Moderator:
Please use the [vb][/vb] tags when you post your code. Edit or reply to this post to see how.

Thank you.

Sending Multiple E-mails
I've got two programs that do some work and then e-mail the results to 4 people. They are set to run in batch mode and will run every day at 4 and 10:30. Everything worked fine when I only had one program on the server. And soon we want to put a third program on the server. This is what happens.
At 4 the first program runs. It sends out the 4 e-mails, but only one makes it out to me, I'm the first in the list, the other 3 e-mails get stuck in the outbox. Then the program runs at 10:30, again it tries to send the 4 e-mails. I get the correct e-mail, the 3 messages in the outbox are sent, and the three that should be sent at 10:30 to the other three people are stuck into the outbox. This happens over and over so the other three people get the e-mail too late. My code for sending the e-mail is below.
And like I said, it would send the 4 e-mails with no problem when there was only one program on the server. The code in both programs used to send the e-mail is identicle.


Code:
'Loop through each name to send mail to
For m = 1 To 4

If m = 1 Then
nameTo = "kkonkle@sigmafinancial.com"
End If

If m = 2 Then
nameTo = "name2@sigmafinancial.com"
End If

If m = 3 Then
nameTo = "name3@sigmafinancial.com"
End If

If m = 4 Then
nameTo = "name4@sigmafinancial.com"
End If

'Set name, subject, message and send mail
With MAPIMessages1
.MsgIndex = -1
.RecipDisplayName = nameTo
.MsgSubject = "Sammons Bonus Dump"
.MsgNoteText = numSent
.SessionID = MAPISession1.SessionID
.Send
End With

Next m

Sending Multiple Varibles To A Sub
I have a sub that I want to send Varables to. In my first write of my code I only needed to send one but how do I send more then one? When I put more in the parentises (eg Sub sendpage(Page As String, index as Integer)) it causes errors when I try to call it. The Error is expected =. What am I doing wrong?

Sending Multiple Reports
~I am using acess 97~

I have created a from that is part of a DB that has a command button set up to send a copy of a report via email. The button seems to work just fine except that it sends every copy of the report in the DB not just the newly created one. The code for it looks like this:

Option Compare Database
Option Explicit

Private Sub save_next_click()
On Error GoTo Err_Save_Next_Click

DoCmd.save acDefault
DoCmd.GoToRecord , , acNext

Exit_save_next_Click:
Exit Sub

Err_Save_Next_Click:
MsgBox Err.Description
Resume Exit_save_next_Click

End Sub
Private Sub Command12_Click()
On Error GoTo Err_Command12_Click

Dim stDocName As String

stDocName = "client contacted"
DoCmd.SendObject acReport, stDocName
DoCmd.GoToRecord , , acNext
Exit_Command12_Click:
Exit Sub

Err_Command12_Click:
MsgBox Err.Description
Resume Exit_Command12_Click

End Sub



Where am I going wrong with this. I am sure its simple and right there in front of my face. Any help would be greatly appreciated.

Thanks in advance

Sending Multiple Attachments - How?
I have tried this code, but it only sends one attachment.


VB Code:
Public Function Send_eMail(sendto As String, Subject As String, Text As String) As Boolean    On Error GoTo ErrHandler    MAPISession1.SignOn    MAPIMessages1.SessionID = MAPISession1.SessionID    With MAPIMessages1        .Compose        .RecipDisplayName = sendto        .AddressResolveUI = True        .ResolveName        .MsgSubject = Subject        .MsgNoteText = Text        For i = 1 To lvwFilesInDir.ListItems.Count            If lvwFilesInDir.ListItems(i).Selected = True Then                If Dir1.Path = "C:" Then                    .AttachmentPathName = Dir1.Path & lvwFilesInDir.ListItems(i)                Else                    .AttachmentPathName = Dir1.Path & "" & lvwFilesInDir.ListItems(i)                End If            End If        Next i        .Send    End With    Send_eMail = True    MAPISession1.SignOff    Exit FunctionErrHandler:    MsgBox "Error " & Err.Number & ":  " & Err.Description, vbCritical, "Cannot send mail"    Send_eMail = FalseEnd Function


What is the proper way to loop through each selected file, attaching it to the message?

Sending SMS To Multiple Receivers
is it possible to send sms to mulitple receivers at once. If yes , then How?

Multiple Values
Inserting multiple values... what would be the best way to do this?

MyConn.Execute ("INSERT INTO Student(Firstname, Lastname) VALUES ('" & strfirstname & strlastname & "')")

getting "Number of query values and destinations not the same" error.

thanks in advanced.

Multiple Values
Does anyone have any insight on getting Crystal Reports to allow for multiple values when used in conjunction with a stored procedure? I am preparing a report that is focused on vendor numbers. The user wishes to be able to search by either one vendor, multiple vendors, or all vendors. The way I prepared my stored procedure allows for all vendors or for a single vendor, but I can't seem to get Crystal to allow for multiple vendors. Does my question make sense, and is there a work around for this problem?

Changing Font Styles When Sending Values To Text File
I'm not sure if this is possible, and probably not but can you change the font style when sending values to a text file using the print command?

like:

print #1, [ bold ] "blah blah" [/ bold ]

thanks

Sending Variables Through Winsock?
is there a way i can send variables through winsock?

Example:

I send strData and strStats.

Then i can do something like

txtDisplay.text = len(strData) "and" len(strStats) with my client?

Need Help Sending Mail With Winsock
All,
I found some good sample code here in one of the posts about using winsock to send emails. I got the code to send an email, but it is only sending the subject line. I need to know where to add the body of the email. I am pasting the code below:

Code:
Dim cur As Integer

Private Sub command1_click()
sckConnect.Connect "xx.xx.xx.xx", 25
End Sub

Private Sub sckConnect_connect()
sckConnect.SendData "Helo me" & vbCrLf
cur = 1
End Sub

Private Sub sckConnect_DataArrival(ByVal bytesTotal As Long)
sckConnect.GetData Data

If cur = 1 Then
sckConnect.SendData "Mail from: [email]me@abc.com[/email]" & vbCrLf
cur = cur + 1

ElseIf cur = 2 Then
sckConnect.SendData "rcpt to: [email]me@abc.com[/email]" & vbCrLf
cur = cur + 1

ElseIf cur = 3 Then
sckConnect.SendData "data" & vbCrLf
cur = cur + 1

ElseIf cur = 4 Then
sckConnect.SendData "subject: Force Withdraw" & vbCrLf
cur = cur + 1

ElseIf cur = 5 Then
sckConnect.SendData "." & vbCrLf
cur = cur + 1

ElseIf cur = 6 Then
sckConnect.Close
End If

End Sub

If anyone can help, I would greatly appreciate it!!!!

Winsock Delays Everything When Sending
i am working on a mutiplayer on-line game. the game itself works fine put when the winsock control sends information to the server, the rest of the game stops for a split second. i have tried using DoEvents but it still does it.

if anyone could help me out, that would be great. Thanks

Winsock Not Always Sending The Things
Making a simple irc client, but winsock just doesnt want to send all the strings I tell it to. It seems like if the user constantly sends text it works okay, but when he keeps a longer break (few minutes) the next string is not sent. Im really frustrated with this. Anyone able to help? Ill try to attach the file.

Sending A File Via Winsock...
I have attempted to send a file through winsock on several occasions throughout the last several years and never have had any success.

Just recently I have found the need to attempt this yet again, and yet again, I simply can't get it to work.

I have looked through dozens of code, tried various ways and what I am about to present to you is the closest I've gotten.

I'm not very good at coding, never have been, probably never will be. If you don't understand why I've done some things the way I did, it may be because of something I need for the rest of the program to function, or simply because I don't know how else to do it.

This is what I have for the client (program sending the file):

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim cnksize As Integer
Dim strdata As String
cnksize = 3072
Winsock1.GetData gotdata, vbString
Label1.Caption = gotdata
If gotdata = "f" Then
fn = GetSetting("x", "data", "filename")
Winsock1.SendData "filename:" & fn
Label1.Caption = "SENT FILENAME"
End If

If gotdata = "1" Then
Label1.Caption = "Connected. Sending data..."
dafile = GetSetting("x", "data", "filesend")
Open dafile For Binary As #1
Seek #1, 1
strdata = String$(cnksize, 0)
Get #1, , strdata
Winsock1.SendData strdata
lngfilepos = cnksize
Close #1
End If
If gotdata = "2" Then
endoffile = GetSetting("x", "data", "eof", "false")
If endoffile = "true" Then
Label1.Caption = "Finished Sending file."
Winsock1.Close
Exit Sub
End If
dafile = GetSetting("x", "data", "filesend")
Open dafile For Binary As #1
Seek #1, lngfilepos
If (LOF(1) - lngfilepos) < cnksize Then
cnksize = (LOF(1) + 1) - lngfilepos
SaveSetting "x", "data", "eof", "true"
End If
strdata = String$(cnksize, 0)
Get #1, , strdata
Winsock1.SendData strdata
lngfilepos = lngfilepos + cnksize
Close #1
End If

so basically on my form I have the drive, dir and file listboxes, so you browse for a file and click sendfile.. it connects to the server and the server sends an "f" indicating to the client to send the filename. All this works great and the file gets sent, but ends up bigger then the original. There are a few extra bytes at the beginning of the file I notice, and even when removed, the file isn't an exact match and is still bigger then the original.

Here is the server code: (by this time in the code it had already sent the client the "f" under connection_request code)

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Winsock1.GetData gotdata, vbString
If InStr(1, gotdata, "filename") > 0 Then
SaveSetting "x", "data", "filetosave", Split(gotdata, ":")(1)
Label1.Caption = "getting " & Split(gotdata, ":")(1)
Winsock1.SendData "1"
issending = True
Exit Sub
End If
If issending = False Then Exit Sub
fn = GetSetting("x", "data", "filetosave", "error.err")
Open "c:" & fn For Binary As #1
Seek #1, LOF(1) + 1
Put #1, , gotdata
Close #1
Winsock1.SendData "2"
Label1.Caption = "doing something"
End Sub

So if anyone has any idea why this doesn't work, please let me know. I would really like to accomplish this task once and for all, since I always end up needing this and usually just give up the project being unable to make this work.

Thanks a lot for your time and I look forward to any replies.

-nomad

Winsock And Sending E-mail
Ok, I made sort of a e-mail client. You fill in the To, From, Subject, and the Body and Click send and it sends it. But sometimes it doesn't connect to the mail server. I am using hotmail (mail.hotmail.com) server. I think the problem is, I am using a timer to push the commands to the server. Which using a timer is not going to be very efficient since if say the 2nd or 3rd bit of data you send is bad or rejected the timer will keep running. So I thought bout taking the timer out and using this as my code:

Code:
Private Sub Winsock1_DataArriva1()
Winsock1.SendData "helo" & vbCrLf : DoEvents
Winsock1.SendData "mail from: " & txtFrom & vbCrLf : DoEvents
Winsock1.SendData "rcpt to: " & txtRcpt.Text & vbCrLf : DoEvents
Winsock1.SendData "Subject:" & txtSubject & vbCrLf : DoEvents
Winsock1.SendData vbCrLf & txtBody.Text & vbCrLf : DoEvents
Winsock1.SendData "quit" & vbCrLf : DoEvents
End Sub
I tested it using that and it gets past the mail from and it just hangs up. Anyone know why it just hangs up?

Sending Image Through Winsock
i'm making this app that that needs to send a pic from server to client using winsock
the pic is about 2mb but is compressed with jpg and the result is somewhere between 30-80kb (depends on quality of compression and the image)

it needs to be sent to the client ASAP so i wondering how to do this:

can i send it in one piece? or is it to big and does it need to be devided into pieces?

and how would i do that, any help would be nice... (remeber speed is an important thing)

Sending Mail - Winsock
I'm looking for a VB program that'll send e-mail through an SMTP server. I made something with information I found on these forums, but it's not really working. I have very limited experience with VB and zero with Winsock.

So my question, does anyone have an example of how this is done? Just the code is important, really, I think I can figure the form part myself.

If anyone knows a good tutorial on this specific subject, that would be great too.

Sending Files With Winsock Dll
yea i would like to know how to send files with winsock using a server/client application. if ne one could help, please do.

thanks in advance

Sending Files Via Winsock Help
im kind of a newb, but if im correct to send a file via winsock would be done like this?


Code:
winsock1.sendata = "C:/somepicture.jpg"

not sure if that is correct, if not could i get help on this? and if yes, then how does the client receive the file so its not in text format and save it to a folder designated for it?


Code:
winsock1_ondataarrival
???

please help?

Winsock And Sending Data
I have had no problem in the past sending and recieving data with winsock. What I am trying to do is this:
Connect to a shoutcast server, download the first bit of info for about 5 seconds, disconnect search through the data sent find the streamtitle identifier figure out the title of the current song and we are done. So I use winsock to connect to the ip listed below. Then I send the data to the ip. Ussually when i have done something similar in the past I would get a response, well this time I don't. I snooped the packets to watch what is happening and I just never get a response from the server. This is exactly the syntaxt Winamp sends the get command to the server, so it should work fine. Any ideas? I know you have to have like 1 or 2 blank lines at the end of the sent item, but that is pretty much ok.

GET /stream/1003
HTTP/1.0
Host: 64.236.34.97
User-Agent:
WinampMPEG/2.9
Accept: */*
Icy-MetaData:1
Connection: Close(I have tried close and keep-alive here)

Winsock Sending Problem
I made a chat room program. The server uses an array of winsocks to connect the people. When one person sends a message every user connected should recieve the message. The problem however is that only one person recieves the message, usually the first person who connected. I have a loop:

For x = 1 to winsock.ubound
winsock(x).senddata(message)
next x

This is supposed to send the message to everyone. I have status monitors and they all say that they are connected, so the connection isnt the problem. When I put a break on the winsock.senddata line all users recieve the message. I thought it was because Im usually testing it on one computer and that the IP addresses were getting confused since they were all the same, but the break I put in there didnt support that and the server is not checking IP addresses. Thanks for any help

Sending Recordsets Through Winsock
I am writing a program for thin clients where client machines have less memory so i would like to write a program which will not require oracle client to be installed on the client.for this purpose i would like to use winsock control to transmit adodb recordsets across network.

Sending Picture With Winsock
I can get the picture when I send winsock to my server, but if I do it again I keep getting the same picture. Here is code I used.

Private Function kuva()
DoEvents
Clipboard.Clear
'Call Keyboard event
Call keybd_event(VK_SNAPSHOT, 1, 0, 0)
DoEvents 'required
'Get the picture from clipboard
Picture1.Picture = Clipboard.GetData()
SavePicture Picture1.Picture, "C:WINDOWSsystem32mitateet.bmp"
DoEvents
'Winsock1.SendData Picture1.Image
'DoEvents
Call SendFile("C:WINDOWSsystem32mitateet.bmp")
End Function

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
Winsock1.GetData strData

If strData = "mitateet" Then
Call kuva
tapahtumat = tapahtumat & vbCrLf & "Kuva pyydetty!"
'Clipboard.Clear
'Call Keyboard event
'Call keybd_event(VK_SNAPSHOT, 1, 0, 0)
'DoEvents 'required
'Get the picture from clipboard
'Picture1.Picture = Clipboard.GetData()
'SavePicture Picture1.Picture, "C:WINDOWSsystem32mitateet.bmp"
'DoEvents
'Winsock1.SendData Picture1.Image
'DoEvents
'Call SendFile("C:WINDOWSsystem32mitateet.bmp")
Else
End If


If strData = "NEXT" Then
'
' The remote host has asked for the NEXT chunk.. so send it to them!
'Call lstEvents.AddItem("Sending next chunk.")
Call SendNextChunk
'
Else
'
' Data has arrived and we're not sure what it is. This shouldn't happen,
' but for debugging purposes, display it.
'Call MsgBox(strData)
'
End If




Private Sub SendNextChunk()
'
Dim hFile As Long
Dim lngChunkSize As Long
Dim strData As String
'
' If we're not currently connected and transferring, exit. This shouldn't
' happen, but just in case...
If (Not blnTransferring) Then Exit Sub
'
' Open the file that we're sending, for BINARY mode. This means that we can
' read out bits regardless of what's in the file (text, image, music etc..).
hFile = FreeFile
Open strFilename For Binary As #hFile
'
' We need to read the next unsent piece of the file, so move through the
' file past all the bits we've already sent. Then, when we read into
' strData, the data will be the next consecutive bytes.
If (lngFilePos = 0) Then lngFilePos = 1
Seek hFile, lngFilePos
'
' Work out how large this chunk is going to be. Normally, it will be the
' standard CHUNK_SIZE, but if the last piece is less than that, decrease it.
lngChunkSize = LOF(hFile) + 1 - lngFilePos
If (lngChunkSize > CHUNK_SIZE) Then lngChunkSize = CHUNK_SIZE
'
' If the chunksize was 0, it means there's no data left to send, so our
' transfer is complete.
If (lngChunkSize = 0) Then

' Send the EOF marker so the remote host knows that's all the data.
'strData = "EOF"
'blnTransferring = False
'Call lstEvents.AddItem("0 bytes, transfer completed. Sending EOF.")
'
' Send the data to the remote host.
'Call Winsock1.SendData(strData)
'DoEvents
'Kill "C:WINDOWSsystem32mitateet.bmp"
'
Else
'
' Grab the data from the file, and increment our file pointer so that next
' time we read, we are reading the next piece of the file.
strData = String$(lngChunkSize, 0)
Get #hFile, , strData
lngFilePos = lngFilePos + lngChunkSize
'
' Send the data to the remote host.
Call Winsock1.SendData(strData)
'Call lstEvents.AddItem("Sent " & lngChunkSize & " bytes")
DoEvents
'
End If

Close #hFile

End Sub
Private Sub SendFile(ByVal strFile As String)
'
' Store the filename for later.
strFilename = strFile
'
'Call lstEvents.AddItem("Sending BOF: " & strFilename)
'
' Set the transferring flag (since we're now connected), and send the BOF
' marker - this instructs the remote host that a file is on it's way.
blnTransferring = True
Call Winsock1.SendData("BOF" & strFilename)
DoEvents
'
End Sub


So everytime winsock gets data "mitateet" It keeps sending the same picture, but picture1.picture changes :S

Sending Packets Using Winsock
Hello!

I am creating a game using Visual Basic 6 for the enjoyment of my friends and myself. I am hoping to have this game online. However, I am stuck on one part.

I have built a nice server. However, I can't seem to figure out how to send packets properly. I know that many people with packet sniffers/editors, people can simply change it and cause havoc on the server. What would be the proper way of sending packets?

The only way to send packets I know is to encrypt the packet before sending it, then decrypting it on the clients end. But this could result in lag if the server has to encrypt before it sends, I think.

If you can explain to me on the best method of sending packets please let me know! I looked this up all over the internet and the result was I found nothing. Please, if you have any tutorials or articles of how this is done let me know.

I've read in a old post that you could use Blowfish (which I am using for the user passwords) to encrypt the packets... Is this correct?

Also, if there are any programmers that would like to help with this project please feel free to contact me . Currently we have two programmers myself doing the server stuff, and my friend doing the game engine itself. We need someone to do level editor and the scripting language for making NPCs.

If you're interested contact me! We are looking for people who do their own work, not modify other peoples work. You can see a screenshot here: http://www.sidrahq.com/images/sidra.jpg It's rather old, just shows we have an engine. It will be based off of Zelda, but we are not using Zelda graphics (just using graphics for testing). We edited the sprites up but its temp We're also looking for graphic artists while I'm at it. Contact me at mack@sidrahq.com or www.sidrahq.com/

Thank you for your time

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