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




Winsock Array Connection Request


i made a post a couple days back gavino answered
im trying to make my multi chat program and well, it isnt goin by too well. for starters the client cant connect

Code:
Private Sub sckSocket_ConnectionRequest(Index As Integer, ByVal requestID As Long)
SockNum = SockNum + 1
Load sckSocket(SockNum)
sckSocket(SockNum).Listen
sckSocket(SockNum).Accept requestID
End Sub
is there sumthing wrong with that?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
WinSock Connection Request Error!
When I use this code for a winsock connection request:

Code:
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
Winsock1.Accept requestID
txtRecive.Text = txtRecive.Text & vbCrLf & "ChatX: Connection Request Detected."
End Sub


I get runtime error 40020:
Invalid operation at current state

when I hit debug it highlights that code snippet up there! HELP

Winsock Server Connection Request Problem
hey, this is my code


Code:
Private Sub wskServer_ConnectionRequest(ByVal requestID As Long)
Dim msgboxResult

msgboxResult = MsgBox("A connect request has been initiated by: " & wskServer.RemoteHostIP & vbNewLine & "Would you like to accept it?", vbYesNo, "Connection Request")

If msgboxResult = vbYes Then
wskServer.Accept requestID
isServer = True
End If
End Sub


now the problem is, whenever i run it, and have a client try to connect to it, this is the error the server gives me on this line "wskServer.Accept requestID"

---------------------------
Project1
---------------------------
Run-time error '40020':

Invalid operation at current state
---------------------------
OK
---------------------------

can someone help?


EDIT: and yes, i did try:
wskServer.Close
wskServer.Accept requestID

but it doesn't work. if u need 2 see my whole code to know whats going on, just let me know

Winsock Connection Prob: "Request To Connection Time Out".
Hi All,

I am developing chat application like Yahoo and MSN messenger. Also i have almost completed it. I have two applications one is server appliation which will be run on chat server machine. the other is client appliation which will be used at any corner of the world.

Its working fine on my network. Ya, it is also working fine over network but with some misbehaviour. Sometimesm, it allow someone to login and sometimes it doesn't and gives "Request to connection time out" error.. I can't find the reason y it is happening.

I have developed this in visual basic and used winsock control.

Matching A Socket Array Number And A A Connection Using Winsock
I'm trying to keep track of a socket array number and the pc that initiated the connection. I'm using Winsock to communicate with up to 30 remote pc's and have to be able to send data at will to pc's. As my code currently stands, pc's connecting with the server all use a certain socket array number. The problem is when I want to link one of these sockets back with the pc's that opened it, my app behaves abnormally as it always uses the first socket that was created.
I have tried linking a socket with the remote host from the server using RemoteHost but this method won't show up the remote host.

Basically, I know the socket array number, so, how can I go back to the host that created it ?

I have read the threads here, but I coul not find any firm reply on this specific issue.

Any help, please ?

Greatly appreciated.

Mike

Winsock Syntax? (To Request A Website With The Winsock Control)
Ok, I don't know very much about Winsock and am just now starting to use it. I'm making an anonymity program that modifies referer and user agent data. I managed to find an example of how its done on planetsourcecode.com but there's a few things that aren't working.

Anyway, when this string is sent, it sends the headers and a request for index.html from the connected host (winsock1.connect domain.com 80).

GET index.html HTTP/1.0
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, application/x-comet, */*
Accept-Language: en
Accept-Encoding: gzip , deflate
Cache-Control: no-cache
Proxy-Connection: Keep-Alive
User-Agent: Whatever
Referer: www.whatever.com

But when I used the website http://ipid.shat.net/ as the domain to see if code mdified the headers or not, it directed me instead to just www.shat.net. How would a browser request information to ipid.shat.net?

Also, I noticed that by sending just that information, cookies don't work properly. What other tags do I have to add onto that for it to recieve my session information? Thanks a lot.

Connection Request
Greetzzz,

I am working with a client and a server. There is no problem when i connect to the client , but when i close the server, and try to run it again ( button: connect) i get the error , the connection is forcefully rejected.

on the client side i have:

[vbcode]
Private Sub Winsock_ConnectionRequest(ByVal RequestID As Long)

Winsock.Close
Winsock.Accept RequestID
end sub
[/vbcode]

on the server side:
(with or without, it doesn't matter)

[vbcode]
Private Sub Form_Unload(Cancel As Integer)
Winsock.Close
End Sub
[/vbcode]


It is only when i close and rerun the client that i manage it to work

Connection Request Interception
how do i Intercept Connection Requests made by Yahoo Messenger and relay the Packets between the client and the server?

anyone?

What Happens To Clients Request Connection At The Same Time?
lets say there is one client that request a connection with a winsock at the same time or... with very small time differences... what happens to the following event:



VB Code:
Private Sub oSocket_ConnectionRequested(ByVal requestID As Long)    'lets say here I have the code   'to accept the call and pass it to another EXE process but    'before  this.. another ConnectionRequest arrives....    'will it wait until this sub is over.. or will it interrup it? end sub

Winsock Request
I have a Winsock component setup right now on my network, exact same as whats in this thread

I would like to know if a similar control can be built using Winsock to do this:


1) Connect to a remote computer, by IP address. (I have a code that determines the IP address of the remote machine already..)

2) Open a .txt file, send it back to (my) the users computer and displays it in a text box on screen.

3) On command button press, take what ever is in my text box, and send the file back to the remote computer and save it.

Kind of like editing a configuration file, remotly.

I know the application would have to be running on the remote end as well as my end for this to work, if its at all possible.

I would really like to do this, I appeciate everyones help in advance!

Winsock Example Request
I'm at work where I can't get to any help files for winsock.  Can somebody give me a quick example of the code required to create a winsock instance, including telling it to listen and respont to internet requests?  I'm going to attempt to make MS Access act like a simple server, and I just don't have the resources here to get it running.  Thanks!

Winsock HTTP Request Help
I need help with this, my wrapper uses winsock to send requests and the close event does not fire which makes the connection stay open forever, my wrapper is at the bottom it is a attachment

WinSock Request Accept
Hey,

I have been trying to get this code to work, It's most likely something stupid am doing, but i cant get my server program type thingie to accept the Request ID from the client program thingie... Here is the code to the part that it says is wrong (If you need anyother parts tell me an i'll post it)


Code:
Private Sub HostSocket_ConnectionRequest(ByVal requestID As Long)

'Show Request In Host Log
HMsg = "Connection request id " & requestID & " from " & HostSocket.RemoteHostIP
HostLog.AddItem (HMsg)

sRequestID = requestID
iSockets = iSockets + 1
ConNumber.Caption = iSockets
Load HostSocket(iSockets)
HostSocket.LocalPort = 1007
HostSocket.Accept requestID

End Sub
PS. I looked at an example to help me with this, so am not sure whats wrong.

Thx in advance.

Ali.

Can Winsock DLL Do Other Protocol Request ...
guys,

i find that the winsock OCX really is limited in its capability...
can anyone suggest me a better one for network programming? because the protocol type is limited to a few only....

I hope to do RTSP / RTP request ... is there any thing that i can used to do that ???

can Winsock Dll do other protocol request or its the total same with the winsock OCX?

Does anyone has a sample using winsock DLL (as client)...??

Winsock : GET Http Gives Me Bad Request , Why?
guys,

is the statement below wrong??

GET http://www.hypermart.com HTTP/1.0


the dataarrival shows me error message...

400 BAD Request

can anyone justify this please?

Multiple Request With Winsock
Greeting,

I have a little problem with winsock. I have a server and several
client. I want to transfer text from server to client trough the network
In this case, I using winsock to transfer the text. It is ok when only 2
computer connected (1 server and 1 client). But, when 3 computer
Connected (1 server and 2 client) I cant broadcast text to all client.

Does any body know how to broadcast text fom server to client trough the
network and winsock?

thanks

Rgds,
Rano Nugrah Agung Homan

Winsock Sample Request
Hi all,

I need to make a server app for my project. I have concluded that I will need to implement Winsock to do so. I have read up on all Winsock articles here (and many others elsewhere) and have downloaded and studied all the samples I could find.

However, I am unable to do what I want because:

- The tutorials say that the IP address or friendly name of the target computer MUST be specified for the Winsock control to connect on the other side. This strikes me as very backward, as I can not always know what IP addresses my customers' network stations will be running on and cannot also predict their friendly names. Does this have to be hard-coded?

- Try as I may, I cannot create a working sample of Server.Exe and Client.Exe to run on the same machine as I cannot afford the luxury of testing my code over two machines. Is there any way I can debug / test on one machine?

If any member proficient with Winsock (Laura Stephens and Jason Rogers come to mind) would like to help, I shall appreciate a small sample to get me started by solving the above two problems.

GoodGuy
Experience is a bad teacher for its exams precede its lessons.

Edited by - GoodGuy on 12/10/2007 10:23:30 PM

[VB6] Winsock POST Request Problem
I'm trying to connecto to google.com and translate a simple word (just to test if works).

And I have a problem when I'm sending POST request data, here is my code:


Code:
Private Sub Command1_Click()
Winsock1.Close
Winsock1.Connect "www.google.com", "80"
End Sub


Private Sub Winsock1_Connect()
Dim packet As String
Dim strpost As String

strpost = "hl=it&ie=UTF8&text=hello&sl=en&sl=en&tl=it&tl=it"

packet = "POST /translate_t HTTP/1.1" & vbCrLf
packet = packet & "Host: www.google.com" & vbCrLf
packet = packet & "Accept: */*" & vbCrLf
packet = packet & "Accept-Language: it,it-it;q=0.8,en;q=0.5,en-us;q=0.3" & vbCrLf & vbCrLf

packet = packet & "Content-Type: " & "application/x-www-form-urlencoded" & vbCrLf
packet = packet & "Content-Length: " & Len(strpost) & vbCrLf
packet = packet & strpost

Winsock1.SendData packet

Text1.Text = Text1.Text & packet

End Sub


Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim data As String

Winsock1.GetData data
Text2.Text = Text2.Text & data & vbCrLf

End Sub



As you can see I want the GETDATA in Text2.Text but I recieve this error:


Code:
HTTP/1.1 411 Length Required
Date: Fri, 01 Aug 2008 13:57:24 GMT
Content-Type: text/html; charset=UTF-8
Server: GFE/1.3
Content-Length: 1357

{html code}


What's the problem?!

Thanks in advance.

How Can You Request A Webpage Using Winsock And HTTPS?
HTTP is easy to form requests with using winsock..
but how can you make requests to a https site?

Wrong Protocol Or Connection State For The Requested Transaction Or Request....
I wrote a small application. It has 2 forms, one which listens on port 5555 and one that sends to it. Form1 listens to it and expects to recieve a byte array and insert it into a udt and print out the values of the variables in the udt on a label. In Form2 the data values are inserted into a byte array which is then sent to port 5555.

When I try to run this application, I get runtime error 40006 "wrong protocol or connection state for the requested transaction or request".

Can someone please look at the code and tell me what i'm doing wrong?

Thanks.

Viewing Cookies Sent With Either Winsock Or INet Request?
Hello,

Is there a way that I can send a request via INET (Most Likely), and read the cookies which were sent with that request?

Thanks

Winsock/cookie Request Entity Too Large...
hi i'm sending a cookie header via winsock but i think it's to large cause I'm receiving a "Request Entity Too Large" in the HTTP Response. is there a way around this?

Winsock - Notification When User Accepts Request
Does anyone know of a way that an initiator of a Winsock connection can be notified when a user on the other end accepts the connection ? I'm new to Winsock, so my terminology might not be the best, but I'm trying to find out if the inititator has any way of knowing that a connection was made before any messages are exchanged?

Thanks for any help....

Does Anyone Have An Example Of How To Send A POST Request With Winsock And A Proxy?
I know how GET works with winsock and a proxy, but how can you use a proxy and use POST?

anyone have an example?

HELP: Winsock To Send HTTP POST REQUEST To A Machine
Hello,

I would like to use visual basic to send data to a machine using an HTTP Post request, and cannot decide on the best way to do it. Can I use winsock. Please bear in mind the following.

I am sending a mult-part message (kind of like an email with attachments). It's actually a multimedia message in the MM7 format -> this is similar to email, a multipart MIME message.

I MUST post to a destination using the following format:

http://192.168.3.75:2097/mm7

I need to then send the data which I've formated according to the MM7 spec.

I need to receive responses from the receving application.

Any help would be greatly appreciated.

Thanks

Ben

Winsock State 8 - Peer Closes The Connection Leaving Winsock High And Dry
I am debugging some web/proxy-serving code. I am stumped.

I get Winsock state 8 - Peer is closing the connection
Then Winsock error message wrong protocol or connection state.

It seems to me that Winsock closes before it can finish sending all of its data.

How can I keep Winsock in state 7 - Connected?


Thanks...

Winsock Connection Prob: "Attempt To Connection Time Out".
Hi All,

I am developing chat application like Yahoo and MSN messenger. Also i have almost completed it. I have two applications one is server appliation which will be run on chat server machine. the other is client appliation which will be used at any corner of the world.

Its working fine on my network. Ya, it is also working fine over network but with some misbehaviour. Sometimesm, it allow someone to login and sometimes it doesn't and gives "Attempt to connection time out" error.. I can't find the reason y it is happening.

I have developed this in visual basic and used winsock control. Any idea regarding this may help me out.

How Can I Make A Control, A Control Array And Upon Request Revert It Back?
VB Version : 6
Hello!I am using the Web browser control in my application.Until now I have not set it an index (at design time) because only an instance of it was needed. Now that I want more instances of the same object I am planning to achieve it by dynamically making it a control array.The problem is that all the related subroutines are referred to the "brwWebBrowser" and not in the "brwWebBrowser(currentIndex)".
So now I cannot go to the design and set the index to wharever.While the Webbrowser control does not conform/apply to any kind of indexing,can I transform it at runtime to be a control array and revert it back to normal?
Something like:

Code:
If chekBox=1 then
'make it a control array
brwWebBrowser.index = 0
else
If chekBox=1 then
'revert to normal (forget all about control arrays)
brwWebBrowser.index=null
end if
end if
Is the below possible?If it is,can I move the last brwWebBrowser (e.g brwWebBrowser (7)) contents into the new one?
Thanks in advance!

Winsock Connection...
ok, im trying 2 make a little instant messenger sorta program, anyways, i have it set up with a radio button so that u either choose to accept messages (server) or send (client). When u press accept and click connect it should just set the local port on winsock1 to whatever the text box for local port is (1412 is what im using). when u press send messages and press connect, it should connect to the ip u entered using the port u entered (127.0.0.1, and 1412). Ok, now, if i make it an exe, open it twice, and set one to be the server and the other to be the client, and presss connect on both, the state of the server side is 0, and the client side goes from state 6 to state 9 (im not sure what these 2 are, but i know 7 is connected). I cant get it to connect to the other program thats open, ill post my code below... and also, if i set the local port on the winsock to port 1412 and connect to port 1412 the program works fine (im doing this without opening the program twice). and i can send messages and all, however it needs to work if some1 were to open the program on different computers. im just gonna post my code for the main form, since the other 2 just tell it to send messages (which work fine if its connected). Hopefully some1 will b able 2 help me out!


Code:
'Declare Variables
Public blnListening As Boolean
Public strMessageTaken As String
Public blnReady As Boolean

'Connect
Private Sub cmdConnect_Click()
If blnListening = True Then
Winsock1.LocalPort = txtLocalPort.Text
frmServer.Show
cmdConnect.Enabled = False
Option1.Enabled = False
Option2.Enabled = False
txtLocalPort.Enabled = False
txtName.Enabled = False
blnReady = True
End If
If blnListening = False Then
Winsock1.LocalPort = "0"
frmClient.Show
cmdConnect.Enabled = False
Option1.Enabled = False
Option2.Enabled = False
txtIP.Enabled = False
txtPort.Enabled = False
txtName.Enabled = False
Winsock1.Connect txtIP.Text, txtPort.Text
blnReady = True
End If
End Sub

'Close Connection
Private Sub Close_Click()
Winsock1.Close
frmClient.Hide
frmServer.Hide
cmdConnect.Enabled = True
Option1.Enabled = True
Option2.Enabled = True
txtIP.Enabled = True
txtPort.Enabled = True
txtLocalPort.Enabled = True
txtName.Enabled = False
blnReady = False
End Sub

'Load Form
Private Sub Form_Load()
Winsock1.Close
If Option2.Value = True Then
blnListening = False
Else
blnListening = True
End If
txtName.Text = Winsock1.LocalHostName
End Sub

'Exit
Private Sub Label8_Click()
Unload frmClient
Unload frmServer
Unload frmConnection
End Sub

'Listening Options:
'xxxxxxxxxx
Private Sub Option1_Click()
If Option2.Value = True Then
blnListening = False
Else
blnListening = True
End If
End Sub
Private Sub Option2_Click()
If Option2.Value = True Then
blnListening = False
Else
blnListening = True
End If
End Sub
'xxxxxxxxxx

'Peridoc1
Private Sub Timer1_Timer()
frmConnection.Caption = "Connection: " + LTrim$(Winsock1.State)
lblYourIP.Caption = RTrim$("Your IP: ") + Winsock1.LocalIP
End Sub

'Connection Request
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
If blnReady = True Then
Winsock1.Accept requestID
Winsock1.Listen
If Winsock1.State = 7 Then
frmServer!rtbMessages.Text = "Connected!"
frmClient!rtbMessages.Text = "Connected!"
End If
End If
End Sub

'Receive Data
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
If blnListening = True Then
Winsock1.GetData strMessageTaken
frmServer!rtbMessages.Text = frmServer!rtbMessages.Text + strMessageTaken
End If
If blnListening = False Then
Winsock1.GetData strMessageTaken
frmClient!rtbMessages.Text = frmClient!rtbMessages.Text + strMessageTaken
End If
End Sub

Winsock TCP Connection
I need to write a little program to send Unix/linux command to a remote PC by LAN connection. I do it now by Hiperterminal and it works fine. I want to write a program to have help in this way:
in Unix/linux if I send ps -e they show me the list of the active process, if i send cd they change directory and so on..............
Now I want to log in and by pressing some botton in the main panel of my program I want to send the command.
I use the winsock and this code:
Private Sub Command1_Click()
Winsock1.Protocol = sckTCPProtocol
Winsock1.Connect Text2, Text3
End Sub

Private Sub Command2_Click()
Winsock1.Close
End Sub

Private Sub Command3_Click()
Winsock1.SendData Text4 & vbCrLf
End Sub

Private Sub Form_Load()
Dim Instringa As String
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Winsock1.GetData Instringa, vbString
Text1 = Text1 & Instringa
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)
MsgBox "ERRORE : " & Description
Winsock1.Close
End Sub
When I press connect (port number 23=telnet)I see in the text1 some characters unknow like this:
ÿýÿý ÿý#ÿý'
If I change the port (21=FTP) I see the welcome message. When I use telnet by hyperterminal (by TCP Winsock on port 21)I don't have this problem......How I can translate it?
I'm sorry for my bad english .Thanks!!!

Winsock Connection Que?
Can someone give me an example of how I would make a client-server program, that the client is in a que and has to wait until its his turn?

Winsock Connection Help
i just get an overflow...

nvm i got it.

right now with this...




VB Code:
Private Sub Command1_Click()Dim x(3) As Datax(0) = &H4x(1) = &H0x(2) = &H89x(3) = &HCWinsock1.SendData (x)End Sub


this worked last time i tryed..now it wont work im sending data as u can see im sending it as HEX

and i get an error..

and... i need to connect to the server and a client..the server connect's but..the client dont for some reson..



VB Code:
Private Sub Form1_load()winsock1.remotehost = "gsproduc.ath.cx"winsock1.remoteport = 9100winsock1.connectwinsock2.remotehost = "127.0.0.1"winsock2.remoteport = 9100winsock2.connectEnd Sub


that isnt the code i have im using the simple part in the winsock control the custom thing...anyways the code i put there is just 2 tell u what i would have if i was putting it in if u get me. ok now the server connect's but the client dont...(if u must know im sending packets to a game server) this all worked out b4 i had 2 formatt my pc so if anyone can help thx alot

-infamouszero-

Winsock Connection
i'm working on networked computers and trying to connect to the computer beside mine using winsock. when my program starts my state will get to 6 (connecting) but never to 7. no matter how many times i loop through the process i can't make a connection! does anyone know why?

UDP Connection With Winsock
problem with udp, when i make a winsock control and i tell it to use the udp protocol it doesn't work. I've read the F1 help file many times over on the winsock control it might have an error or two on it. I can make a tcp/ip connection fine, but I want the ability to make a udp connection. here is the code if you can find anything to improve or help me, then I would be thankfull


Server side code:

Private Sub Form_Load()
Winsock1.LocalPort = 2020
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim incomedata As String
Winsock1.GetData incomedata, vbString
Label2.Caption = incomedata
End Sub

Client based code:

Private Sub Command1_Click()
Winsock1.SendData ("testing")
End Sub

Private Sub Form_Load()
Winsock1.RemotePort = 2020
Winsock1.RemoteHost = "192.168.1.2"
End Sub

Winsock Connection
winsock connection does not re-establish for 5minutes atleast after the connection has broken. this is sometihng i really dont want in my vb chat .


any suggestions ?

Winsock Connection
I am trying to create a client/server application with the client side having multiple forms. I am trying to establish a winsock connection and remain connected throughout all forms until the user logs off however i cannot establish the connection in the first place . I thought about using modules however i am unsure how to create a winsock connection using this method.
This is the code i am using at the moment in the client side;

[VB]
Private Sub Form_Load()
lblip.Caption = WS.LocalIP
WS.RemoteHost = "ipaddress"
WS.RemotePort = 1001
End Sub

Private Sub cmdconnect_Click()
WS.connect
End Sub

[/VB]

this code however does not allow a connection
Any suggestions on how this could be acheived would be most welcome.

Winsock Connection
Can any1 see why my winsock won't connect =)...(Doesn't make it to DataArrival Sub), prolly something stupid, but yeah, Can't see it :P


Globals.

Code:

Dim lstLoaded As New clsLB
Dim lstFound As New clsLB
Dim ID(1 To 60) As String





Start

Code:

Private Sub cmdStart_Click()

Dim i As Integer

If lstLoaded.ListCount < 1 Then
Exit Sub
ElseIf lstLoaded.ListIndex = lstLoaded.ListCount - 1 Then
Exit Sub
End If

Call RotateUsers(lstLoaded, lblCountLoaded)

For i = 1 To cmbSockets.Text

ID(i) = txtBefore.Text & lstLoaded.Text & txtAfter.Text
Winsock(i).Close
Winsock(i).RemoteHost = "profiles.yahoo.com"
Winsock(i).RemotePort = 80
Winsock(i).Connect
Call RotateUsers(lstLoaded, lblCountLoaded)


Next i
txtStatus.Text = "Connecting..."

End Sub





Connect

Code:

Private Sub Winsock_Connect(Index As Integer)

Dim Packet As String

Let Packet = "GET http://profiles.yahoo.com/" & ID(Index) & "HTTP/1.0" & vbCrLf
Let Packet = Packet & "Connection: Close" & vbCrLf
Let Packet = Packet & "Accept: */*" & vbCrLf & vbCrLf

txtStatus.Text = ID(Index)

Winsock(Index).SendData Packet

End Sub

Winsock And IRC Connection
Ok you're all probably getting sick of my posting about problems with my IRC client I'm coding in VB6. I'm getting it to connect to the IRC server, its getting the following messages back:

Quote:
Connected to irc.hackthissite.org...

:irc.hackthissite.org NOTICE AUTH :*** Looking up your hostname...
:irc.hackthissite.org NOTICE AUTH :*** Found your hostname

This is all fine and good. What it does is connect to the server, uses the winsock.getdata function to grab the incoming data from their server and then prints it to my multiline chat textbox. After the "Found your hostname" line, usually (when I use telnet) I can type in "user username 127.0.0.1 localhost :realname", hit enter, type "nick username", hit enter, and then "pass *" and hit enter and it replys with all sorts of good messages, and from there I can join channels and chat and stuff. however, in my vb6 client, when I try to send the first "user username 127.0.0.1 localhost :realname" command it either isn't sending it or it just isn't working. I've added code to check the connection state (equals 7) before sending this line.
what happens is it hits the winsock.senddata line, and then I have it check for incoming data using the winsock.getdata line, which is in a loop for awhile until it gets data. but its not getting any data.
I also have a timer set which every 1000 miliseconds, checks for PING's in the incoming data buffer lines and also prints any incoming data to the screen. It doesn't appear to be seeing any incoming data either.
so basically, after the above output, my progam just sits there, connected, but not doing anything. if someone could help me with how exactly I send data and check that it sent properly, that would be great.
I know I have to check for pings and reply with pongs for my connection to stay up. what I'm not sure of is if I need to use a second winsock control which listens on the Ident port, listening for IdentD packets. This could be part of the problem, but I'd like to know if anyone else has tried writing their own IRC client using VB6 at all. does anyone know the raw transactions that occur between client and server during an IRC server connection/identification?? I'm not very knowledgeable on the Ident stuff, all I know is that the IRC server checks on like port 113 or something (Ident port) to make sure my hostname is correct. Maybe I need this, I'm just not sure.
Any help would be great, even if you only want to crap out your 2 cents worth on the idea.




Edited by - wagnj1 on 8/27/2004 7:37:18 AM

WINSOCK Connection
How do i set up winsock so it connects to the msn server.

Winsock, Connection Over The Net... HELP
OK, i have made a chat program, and i have downloaded several example source codes, but, out of about 5 so far, NONE will work over the internet, although i have a firewall i dont think thats the problem, can some one please link me or send me source code that you KNOW works over the internet (2 outside ips connecting, for example Trillian or AIM)

A direct link to source code or faq please, none of this www.vbcity.com! . . . . .



Edited by - bill6131987 on 1/16/2004 3:37:50 PM

Sharing A Winsock Connection
I am working on a Client/Server application. I have two forms on the server side, but I stuck all of the code in only one form. I want to be able to share the winsock connection to both forms without coding a compete second form. Is there a way to do that?

Passing A Winsock Connection Help
Is it possible to pass a connected winsock control to another ip and port without closing the connection first? Its possible in delphi and other languages.. Please help

thanks in advance

Winsock Connection Problem
Hi

I'm looking to improve a system here which displays what PCs are being used in our Computer Centre - we use it to get an idea of useage.

One idea I've thought about, after browsing Visual Basic help is to use Winsock.

There is an example on the VB help which gives you a demonstration which I'm hoping to adapt for my own needs.

The problem is is it keeps crashing.

The example asks you to type info into a box. The resulting input would come in on another box on another form.

Its gets to winsock.SendData (udpPeerA/B.SendData in the code) and crashes with a Run-Time Error 10014.

Would it be security issues here (its all running off my machine) or something else.

Also, as a thought. Would this be the best way to deal with my problem as there maybe many computers trying to connect to the server at once.

For reference, here is the code I'm using:

This is Peer 1:

Code:
Private Sub Form_Load()
' The control's name is udpPeerA
With udpPeerA
' IMPORTANT: be sure to change the RemoteHost
' value to the name of your computer.
.RemoteHost= "PeerB"
.RemotePort = 1001 ' Port to connect to.
.Bind 1002 ' Bind to the local port.
End With
frmPeerB.Show ' Show the second form.
End Sub

Private Sub txtSend_Change()
' Send text as soon as it's typed.
udpPeerA.SendData txtSend.Text
End Sub

Private Sub udpPeerA_DataArrival _
(ByVal bytesTotal As Long)
Dim strData As String
udpPeerA.GetData strData
txtOutput.Text = strData
End Sub

Peer 2:


Code:
Private Sub Form_Load()
' The control's name is udpPeerB.
With udpPeerB
' IMPORTANT: be sure to change the RemoteHost
' value to the name of your computer.
.RemoteHost= "PeerA"
.RemotePort = 1002 ' Port to connect to.
.Bind 1001 ' Bind to the local port.
End With
End Sub

Private Sub txtSend_Change()
' Send text as soon as it's typed.
udpPeerB.SendData txtSend.Text
End Sub

Private Sub udpPeerB_DataArrival _
(ByVal bytesTotal As Long)
Dim strData As String
udpPeerB.GetData strData
txtOutput.Text = strData
End Sub

Cheers for any assistance.

Neil.

Connection Error Winsock API.
Im using this code here in order to connect to my server which uses Winsock.OCX file. This below code is for the client which I got off a winsock API website. What is happening that for some reason when a server is being hosted, with IP and port both open for communications (no firewall etc), the client will not connect (with code below). However it's weird when I host the server side program on my friends computer it connects fine, but when it's on a dedicated server it does not work. Is there anything here fairly obvious out of order? It sort of seems like when it's on a dedicated server with a few IP's it dosen't know which one to connect to or something even though it's specefied, im lost


Code:

Call CloseSocket(lngSocketHandle)
Let lngSocketHandle = 0
enti = ip
enti2 = port


Dim lngHostName As String
Dim udtSockaddr As SOCKADDR_IN

'Switch the socket so that it does not block.
Call ioctlsocket(lngSocketHandle, FIONBIO, 1)

'First create a new streat socket that uses the TCP protocol
Let lngSocketHandle = Socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)

'Error checking
If lngSocketHandle <= 0 Then
MsgBox "Connection Failed", vbCritical
Exit Sub
End If

'Try to resolve the host name to the long address.
'This function will work if it was an IP
Let lngHostName = inet_addr(enti)

'If it didn't work...
If lngHostName <= 0 Then
'Try the gethostbyname function. This will work for aliases like "www.microsoft.com"
Let lngHostName = gethostbyname(enti)

'Some more error checking
If lngHostName <= 0 Then
MsgBox "Connection Error", vbCritical
Exit Sub
End If
End If

If Not IsNumeric(enti2) Then
MsgBox "Port Based Error", vbCritical
Exit Sub
End If

'Fill out the socket address structure to ready the connection
With udtSockaddr
Let .sin_family = AF_INET
Let .sin_addr = lngHostName
Let .sin_port = htons(CInt(enti2)) 'Remember: Network byte order
End With

'Switch the socket so that it blocks and the connect function returns straight away
Call ioctlsocket(lngSocketHandle, FIONBIO, 0)

'Call the connect function
If connect(lngSocketHandle, udtSockaddr, Len(udtSockaddr)) = -1 Then
MsgBox "Connection Error", vbCritical
Call CloseSocket(lngSocketHandle)
Exit Sub
Else
connected.Enabled = False
disconnect.Enabled = True

End If

'Switch the socket so that it does not block.
Call ioctlsocket(lngSocketHandle, FIONBIO, 1)

Winsock Connection Problems
Hey

I am having some trouble with connecting to some sockets. I have 2 programs one which has multiple sockets all awaiting incoming connections and one that has 1 socket that connects to, sends information from and receives information from the other program.

I get no connection when trying to connect to the Server if you will (the program with multiple sockets in an array). I have attached my projects in *.zip form. Could someone please have a look and tell me where I may be going wrong so I can fix it.

Very much appreciated.

Phantom Winsock Connection
When a client/server are connected over winsock, the computer that loses their TCP/IP connection (ie. disconnecting CAT5 cable or disabling wireless networking on a laptop) will remain connected, the actual Winsock.State remains "sckConnected" (7)... The other computer properly disconnects... Is there a way to verify that the Winsock connection is still valid while it is connected.. I tried retrieving the RemoteIP and RemoteHostName but I think there buffered on connection and not retrieved upon request... any suggestions, that don't include parity bits sent back and forth would be appreciated... thanks

Decline Connection With Winsock
here it is:

my app has an array of three winsocks, 0,1 and 2.

0 listens for connections and .tag is set to "1" (im using that for 'in use')
winsock(1).tag = "0" (not in use)
winsock(2).tag = "0"

winsock(0) recives a connection request then connects to a socket that isnt in use

i can now connect two people to my server. The problem comes when i connect a third. i get an error and the server closes.

is there a way i can decline a connection if all my winsocks are .tag = "1" (in use)?

Multiple Connection Winsock
hello all
i am writing a dialer program and want to use winsock to connect the client to the server server. i was wondering what the best way to go about this would be.
there will be 24 clients per server, the client will connect to the server and send its ip address, username, campaign name and station id.

the server will use this information to set up the que and its winsock control to that ip address

then it will need to be able to send records to the clients as calls are received

the question i have is what is the best way to go about this, i dont want to start and then find out that i could have done it better a different way, please help

Winsock Tcp Connection Check
Hello everybody.
I have written in VB6 a server-client chat-like application based on the winsock component.
I establsh a TCP connection to each client using an array of Winsock controls.
Every time a user connects to the server, it sends to every connected user the updated list of the connected clients.
The only thing i can't figure out is how to check whether my clients are still connected (if somebody shuts down the applicatio properly there's no problem since the client sends a packet telling the server it is shutting down, but if the application freezes or the computer is resetted this doesn't work, obviously). Is there anyway I can check if the other host is "still there"?
Thanks in advance
NeT

Using An Existing Winsock Connection
For my chat program, I am developing plugins for people to use. I want to be able to send data through winsock (on a form in my activex dll project), but my main chat form is already connected to the server. Is there a way I can send data through a winsock control that is already connected without getting a: "Address in use" error?

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