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




Winsock - Connection Is Forcefully Rejected


Winsock - Connection is forcefully rejected

I have a client and a server. That's about it, the problem occurs when I connect to the server and then disconnect. When I go to reconnect again, I get the message "connection forcefully rejected"

CLIENT:

Private Sub cmdConnect_Click()
Socket.Close
Socket.RemoteHost = "localhost"
Socket.RemotePort = "1500"
Socket.Connect
End Sub

Private Sub cmdDisconnect_Click()
Socket.Close
lstLog.AddItem "Connection closed"
End Sub

? Shouldn't I be able to reconnect once the connection is lost? Also, when you use winsock1.close does the winsock_close get fired? so when you call that winsock1.close all information, commands etc. under winsock1_close runs?

Thanks,
Gabe




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Winsock: &"Connection Is Forcefully Rejected&" Error
I have written two programs, a client and server program. The client connects to the server, the server sends data and then closes the connection, then goes back to listen for more connections. The client connects fine, and everything goes like it should, but when I try to connect again (without resetting the server) I get a "Connection is forcefully rejected" error. Why? The server's state is 2 (listening).

Disiance

Connection Is Forcefully Rejected. ??!!
Hi,

I've followed some posts here and manage to make a client/server app.

Now i have a problem :

The server is always running, and the ckient is not. The 1st time the client is used everything is ok, but if i close the client and then open it again i get this error :

Error 10061 Connection is forcefully rejected.

Any ideas?

Thanks

Connection Forcefully Rejected AOL 8
After hours of trying to figure out the solution to this error: Connection Forcefully Rejected, I think it is AOL!! I have made a communications program like a messenger that just sends messeges like IMs. But when I was testing it with a friend, his internet connection was through AOL 8.0 Plus. Kept getting the error and then all of a sudden he tried going on to regular AOL 8.0. The program worked fine!!

So my question...why will it not work with AOL 8.0 Plus? Is there like an added built in firewall or something?

Is there something I can change or add to the code in order to get it to work properly?

thanks

Connection Is Forcefully Rejected
Hi,

I wrote a piece of commercial software that downloads some files off my server to the user's local machine. The trouble I'm having is one customer of mine repeatedly gets the error message, "Connection is forcefully rejected," which is very hard for me to troubleshoot with her, since she has such little technical knowledge.

The code works flawlessly on every computer besides hers so far. So I'm thinking she has some unusual system configuration. I tried crashing the file transfer every which way on my own pc, but I can't get it to raise that particular error. I wasn't able to find much about this on google.

Are there any common causes for this error, such as firewalls, ports, etc.?

It's a simple http:80 downloader.

Just let me know what more information you need.

Thank you.

&"Connection Is Forcefully Rejected&"
First things first, this my first time here, so a quick hi to everyone!

Now down to business.
So here's what I've got. I've created two seperate projects, with one form each, in Visual Basic 6. The idea behind this little idea of mine is to open up one project on one computer to act as a server, and the other project, the client, on a seperate computer. Both forms are pretty similar, but not exactly the same, as ones meant to act as a server, while the other just connects to it. So, I load up the server project and open up the connection, but the moment I try to connect from the client, I keep getting a "Connection is forcefully rejected" error. Now, I've downloaded another example onto both computers that does pretty much the same thing... and it works fine; no errors. So my question is: what's the usual problems assosiated with that error? Is there something specifically wrong with my program, hopefully something that can easily be changed? Any help or ideas would be greatly appreciated, as this is quite the urgent matter.

Thanks in advance.

Forcefully Rejected
I am trying to make a simple chat program, for over the internet, please can someone provide information on the ports and stuff because on my program i get the "forcefully rejected" error message!!!

Client winsock codes are:

Private Sub lblConnect_Click()
Dim IP As String
IP = cmbIP.Text
Winsock.RemoteHost = IP
Winsock.RemotePort = 12345
Winsock.Connect
cmbIP.AddItem IP
If Winsock.State = 7 Then
End If
End Sub

Private Sub Winsock_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
Winsock.GetData strData
lstMain.AddItem vbCrLf & strData
End Sub

Private Sub Winsock_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)
' an error has occured somewhere, so let the user know
MsgBox "Error: " & Description
' close the socket, ready to go again
' lblStatus.Caption = "Disconnected"
End Sub

and Server code is :

Private Sub Form_Load()
Winsock.RemotePort = 12345
Winsock.Listen
' Your username
End Sub

Private Sub Winsock_ConnectionRequest(ByVal requestID As Long)
People = Winsock.RemoteHostIP
Winsock.Close
Winsock.Accept requestID
If chkSlient.Value Then
Else
MsgBox "Some as connected IP: " & Winsock.RemoteHostIP, vbOKOnly, "Someone's Connected"
End If
End Sub
Private Sub Winsock_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)
' an error has occured somewhere, so let the user know
MsgBox "Error: " & Description
' close the socket, ready to go again
End Sub
Private Sub Winsock_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
' get the data from the socket
Winsock.GetData strData
' display it in the textbox
lstMain.AddItem vbCrLf & strData
' scroll the box down
'lstMain.SelStart = Len(lstMain.Text)
End Sub
==============================================

I thought i was doing everything right. And yes i have been on www.winsockvb.com. Well im off to bed! Hope for a reply in the morning!

Thanks in advance! (EVBF admins you rock!!!!)

Winsock - Connection Rejected
Folks....

I have my VB program connected to my controller via an ethernet cable. The unit connects fine and everything works so what i am doing now is testing every possible problem...
When i close the program at the controller end, the PC (running VB) recoginises this and flags an error.
HOWEVER

when i try to reconnect(after restarting the controller) i get the message..."Connection i sforcefully Rejected" Error 10061 at the VB end? WHY???

The only way for me to solve the problem is to close both programs and restart from scratch....Does the network port need flushing? If so, how do i do this???

Matt

Forcefully Closing A Connection To A Specific Host
first and foremost, I'm not looking for a way to close an internet connection. I need to get a list of all of the open connections (similar to typing 'netstat -a' on the command line), and then I need to close a specific one. Is there an API or a component that will do this?

Thanks,
Chris

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...

Forcefully
I now have a program that closes specified applications by using their title and closing it with a postmessage using its handle. Some programs say "are you sure you want to exit" is there a way to forcefully close these applications so that the user does not have a choice? (For admin purposes of my security program)

ActiveX DLL Call Was Rejected By Callee
Okay, having a bit of a nightmare so any help would be greatly appreciated as I think my head may explode soon.

We have a Windows 2K server running SQL Server 7. A sp makes calls to an VB 6 ActiveX DLL that retrieves data from the database and inserts it into Word templates. This runs fine for most of our templates apart from one, the one with the most data. On this one we get the automation error "Call was rejected by callee".

Now I have been all over the web looking for a solution to this and cant get anywhere, I cant reset the OLEServerBusyTimeout property in an ActiveX DLL and I have tried having "sleeps" and then retrying the call.

It is not a data problem as after having put in some debug messages it fails while populating different bookmarks for different records, although it always does seem to fail roundabouts the 20 minute mark.

Has anyone got any fab ideas?

Thanks.

L.

Forcefully Remove DLL From Memory
Hi there

One more question: Is there a way to forcefully remove a dll or exe from memory programatically without having to reboot the system?

Or how can I find the process id of a process if i only know the filename of the executeable that started the process?

Thanks for your input,
Daniel

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.

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 You Forcefully Close A Process Based On Its Hwnd?
Not just by sending the WM_CLOSE signal, but forcefully closing it..

Close Any Open File Forcefully? Or Unlock It??
Close Open File Forcefully or Lock/Unlock the File???

At times, from P2P download clients, I may get some error if I try to delete the file. "Unable To Delete File. Please Make Sure all programs using this file are closed" something along those lines anyways. Is there a way to forcefully close this file? Because even after closing the download client and even running in safe mode, you still cant delete the file. The Only way to delete it is to boot up in command prompt mode and delete it in the DOS interface!!!!!. This gets EXTREMELY annoying!, especially with large file names. So is there a way to forcefully close the file?

Also, I have read some articles on Databases/Records. Do Download Clients Lock certain sections of the Data/Text? If so, is it possible to determine this locked data or how much of it is locked, and then unlock it?

All Replies are appreciated

Andrew

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?

Winsock Connection Problem
Hi,

I am designing a program Visual Basic 6.0 to check connected machines to a net using winsock. It is very much like a chat program. In this case, I want to control what people do. I have a list that reports running programs, etc. But, I have a server and a client program. Most of the machines get connected to the server computer but 2 of them do not. One of these computers used to connect as the others but not anymore. I have reinstalled the program. Check the code but nothing. I load a winsock for each computer I connect. I verify the winsock ubound and add one more. I verify if the subroutine connectionrequest gets info from the problem machines but nothing happens. The rest of the computers do it and I even get their names sent to the server. A treeview shows all machines in the network. I create a lit box to show me all running programs in each of the machines whenever I click on them. If I want to send a message, I send the order, a sub decodes it and execute whatever I want the client computer to do. That is OK. The problem is that the 2 computers that are missing connection don't even send the request to the server. The other computers do it perfectly and that is why and don't understand what the problem is. I have checked the winsock dll and vxd. I have reinstalled the network drivers. I even changed the ethernet card but nothing. I also checked the network properties. I check the tcp/ip in all computers and they are the same. The DHCP is active and the IP address is automatically detected. The program is running under windows 98. I don't know if that makes any difference. This is driving me crazy. Well, if some more info is needed, please let me know.

Thank you very much in advance.

Refreshing Winsock Connection?
Hello, im making a chat program with some extra featz, like sending a message box to another person, the code to send the message box works fine once, but the 2nd or 3rd time when i try it it doesnt send any messageboxes at all, but i dont get any error either. Is there a way to refresh the connection or set forcus to the connection.

LAN Or Dial Up Connection With Winsock
Hi,

I made a program that communicates to a server via winsock.
I have a LAN connection and a Dial Up Connection available to the server.

The question is, How can I specify to the application to use one or the other connection.
When I have the 2 connections active the application communicates through the LAN connection, but I want it to communicate over the DIAL up. How do I do that?

Thanks

WinSock Connection Error
Ok....I have 2 Textboxes. Text1 is the IP which to connect to, and Textbox2 is the port.

In my 1st command button I have

Winsock1.Connect Text1.Text, Text2.Text

It was working fine for a few and now it says it's an error.

How is there an error? I see no error? I'd state the permanent IP address, but it may vary, so I'd like to keep it reading off of a target text box...

is wrong with this thing?

New Form For Each Winsock Connection
Hello, a few days ago i posted on how i could have an instance of a form to be shown for each winsock connection. For example, user a connects to my machine, an a form contaning a text box shows the data received by user a. If user be were to connect while user a is still connected, an additional dialog form would load, and user b's data would appear in the newly loaded form.

In the program i have written so far, a new form loads when a new connection comes in. However, each connection does not stay with the form it should be. For example, user A connects, and has a form for its data. When user B connects, a new form is loaded, but both data for user A and user B come into the form meant for user B's winsock connection, and the old form that was meant for user A stays idle with the data that was sent by user A before user B connected.

How do i get it so that, say if users A B and C were to connect, each of their winsock connections would be in separate forms, whereas each of the separate forms display the data for that users connection? Below is my code.
Please help! =)

--------------------------------------------------------------------------
Public f As New frmConn

Private Sub Form_Load()
Timer1.Interval = 500
Timer1.Enabled = True
ProgressBar1.Max = 10
socket(0).LocalPort = 333
socket(0).Protocol = sckTCPProtocol
socket(0).Listen

End Sub

Private Sub socket_Close(Index As Integer)
socket(Index).Close

End Sub

Private Sub socket_ConnectionRequest(Index As Integer, ByVal requestID As Long)
Dim y, x As Integer

Set f = Nothing
y = Int(Rnd() * 9600) + 1
x = Int(Rnd() * 16000) + 1
Load socket(socket.UBound + 1)
f.socket2(Index) = socket(Index)
socket(socket.UBound).Close
socket(socket.UBound).Accept requestID
f.Show
f.Top = y
f.Left = x

End Sub

Private Sub socket_DataArrival(Index As Integer, ByVal bytesTotal As Long)
Dim data As String

socket(Index).GetData data
f.Dialog.Text = f.Dialog.Text & data

End Sub

Private Sub Timer1_Timer()
Static counter As Integer

counter = counter + 1
ProgressBar1.Value = ProgressBar1.Value + 1
If counter = 10 Then
Me.Hide
Timer1.Enabled = False
counter = 0
End If

End Sub
--------------------------------------------------------------------------

Please note that this code is for the main splash screen. the dialog form has its own winsock control (we try and use this to make a reference to socket(index), but there is no code/project for the dialog form.

Database Connection Using Winsock Over Lan
does anyone have code (or suggestions) for connecting to an ms Access database over a lan using winsock?

I am trying to set this up without having to set up sharing privledges for the folder on our network (sharing would allow anyone to delete the database at anytime)

thanks

Encrypting A WinSOCK TCP Connection!?
How would I go about doing this? I have alreayd made the progrma generate a psuedo-randomized encryption code: (here is an example)


Code:
x1980y36s0b0x1800y72s0b0x1668y132s0b0x1584y168s0b0x1548y180s0b0x1536y192s0b0x1536y204s0b0x1560y216s0b010201211042412848415481561908228x3012y528s0b0x3456y576s0b0x3684y600s0b0x3816y612s0b0x3852y612s0b0x3876y612s0b0x3888y612s0b0x3852y588s0b0x3816y588s0b0x3780y588s0b0x3696y588s0b0x3564y564s0b0x3360y540s0b0x3132y516s0b0x2880y504s0b0206424019082161836216178819217761921908216x2748y516s0b0x3180y576s0b0x3816y600s0b0x4392y600s0b0x4812y600s0b0x5088y600s0b0x5376y552s0b0x5544y492s0b0x2244y240s0b0x2256y228s0b0x2208y216s0b0x2136y192s0b0x2052y192s0b0x1920y192s0b0x1716y192s0b0x1248y156s0b0x612y132s0b0x3276y300s0b020402416560x2076y228s0b0x1980y228s0b0x1932y228s0b0x1920y228s0b0x2052y228s0b016560205224x3192y324s0b0x336y144s0b0x828y204s0b0x1080y228s0b0x1260y228s0b0x1368y228s0b0x1416y228s0b0x1452y228s0b0x1404y228s0b0x1368y204s0b0x1248y204s0b0x996y204s0b0x708y204s0b0x324y204s0b0x3312y444s0b0235220420642041860156175214416921441668144170414418241442076144x3180y384s0b0x612y72s0b0x1452y36s0b0x1944y0s0b0x2172y0s0b0x5616y216s0b0x5640y204s0b0x5640y180s0b0x5640y168s0b0x5604y144s0b0x5580y144s0b0x5544y120s0b0x5448y120s0b0x5244y120s0b0x4980y132s0b0x4548y216s0b0x648y0s0b0x120y0s0b0x3012y240s0b0216001932018240x2364y216s0b0x2340y216s0b0x2328y216s0b0180012193248229296x132y168s0b0x720y228s0b0x4476y516s0b0x4752y516s0b0x4884y516s0b0x4944y516s0b0x4944y504s0b0x4908y492s0b0x1524y228s0b0x1500y204s0b0x1464y204s0b0x1380y204s0b0x1200y204s0b0x924y204s0b0x648y204s0b0x264y204s0b0x3288y420s0b0x3012y396s0b02196132206410820161081992108202810821241082256108x3060y348s0b0x3312y348s0b0x228y108s0b0x576y108s0b0x900y108s0b0x1128y108s0b0x1224y108s0b0x1272y108s0b0x1272y96s0b0x1236y72s0b0x1188y48s0b0x1056y48s0b0x804y48s0b0x492y48s0b0x12y48s0b0220848163248126048840485884843260348603126030060300723721205281441008216x2340y492s0b0x3024y528s0b0x3660y528s0b0x4032y492s0b0x888y216s0b0x972y204s0b0x996y180s0b0x996y168s0b0x960y156s0b0x936y144s0b0x912y120s0b0x888y120s0b0x792y120s0b0x540y120s0b0x192y120s0b023641441836144136814411401441008144972144948144984156108016813081681812168x3192y408s0b0x612y168s0b0x1200y192s0b0x1524y192s0b0x1644y192s0b0x1692y192s0b0x1692y156s0b0x1656y144s0b0x1620y132s0b0x1572y120s0b0x1452y108s0b0x1176y108s0b0x828y108s0b0x300y108s0b0x3240y348s0b0228010819921081872108178810817641081752108177612018841442124144x3336y384s0b0x960y144s0b0x1896y144s0b0x2676y144s0b0x6324y384s0b0x6396y336s0b0x6360y324s0b0x6276y312s0b0x2712y72s0b0x2436y72s0b0x2052y72s0b0x1632y72s0b0x1104y72s0b0x732y72s0b0x408y84s0b0x180y84s0b0x0y96s0b0x3276y336s0b0x3252y336s0b0x3240y336s0b0x3240y348s0b0x3288y384s0b0x84y204s0b0x3816y516s0b0x4476y648s0b054961257004857844857964857482456881256160x3684y696s0b0x3240y636s0b0x3012y624s0b0x2904y576s0b0x2868y564s0b0x2856y564s0b0x2844y552s0b0x2868y540s0b0x2940y540s0b0x3048y540s0b0x3180y576s0b0x3264y588s0b0x3324y600s0b0x3384y624s0b0x3324y624s0b0x3264y624s0b0x3228y624s0b0x3108y624s0b0x2856y624s0b0x2472y624s0b0x1824y552s0b0x1176y492s0b01801920156x516y384s0b0x492y384s0b0x516y360s0b0x588y360s0b04812084120108132144132252144516168x1824y492s0b0x2868y564s0b0x3864y600s0b0x4500y636s0b0x4728y636s0b0x4776y636s0b0x4716y636s0b0x4632y612s0b0x4548y600s0b0x4476y600s0b0x4368y600s0b0x4188y600s0b0x3936y552s0b0x3576y528s0b0x3180y480s0b0207614417289615246014162413680x1956y228s0b0x1968y228s0b0x2016y228s0b0x2040y228s0b0x2076y228s0b0x2136y228s0b0x2184y228s0b0x2208y228s0b0x2232y228s0b0x2256y228s0b0x2268y228s0b01632016080158401536015120148801464014520142812141612140412140424141624146424152424154824158424160824165624169224172824177624178824181224182424182412181212178812177612175212172812166812163212158412154824153624152424153624162036172836186048196872205296211296213612021481202160120213612021121202052120199212019201201872120183612018241201812120180012018121201872961932841980842016842076842100842124842100842088842052842004841968841920841908841884841884721896721920721968721992722016722028722040722028722016721992721980721956721932721920721932721944721932721920721908721908601908481908241908481908961908216x2508y540s0b0x2508y612s0b0x2508y660s0b0x2508y672s0b0x2520y636s0b0x2520y612s0b0x2520y588s0b0x2520y576s0b0x2520y564s0b0


What exactly would I do now? I started a winsock listener, but what now? (and on the client side I started a winsock.connect "HOST" "PORT")..

How would I encrypt it's packets ? (Past just scrambling hte data sent and recieved using on dataarival and datasend)

WinSock Connection Reset
When my connection is reset, I get error 40006. I'm unable to find a way to reset the socket so I have have it connect again.

How do I reset it to make the control usable again?

Winsock Kick Connection
Hi all,

I am creating a chat server and client and i need a way that:

a) usernames can be sent to the server and listed
b) How do i kick a remote connection so the server can kick a client connection.

Thanks!

Ross

Winsock Multi Connection
hey,

ive been searchin around the forum and some good websites i have found for a tutorial on how to make multiple connection with a winsock, say i have a server that any number of clients can connect to and when they send a text it pops up in a message box or something, the main point is i need to know how to make multiple connections, i have seen things such as


VB Code:
winsock(index) 'and also winsock(0)


please can someone explain this or give me a link to a goods tutorial
thanks

VB6 - Winsock - Check Connection
Hello:

I have a VB6 client/server app using Winsock features and am having some problems with it.

On the client side, I have a series of commands like the following:

If Winsock1.State = sckConnected Then
Winsock1.SendData ("Ad1Break")
TotalSent = TotalSent + 1
Label2.Caption = "Total Script Commands Sent to Server: " & TotalSent
End If
End Sub

However, after the client has been running for a long period (anywhere between 30 and 1 1/2 hours) without sending any commands to the server, even though it reports its status as CONNECTED, it does not successfully transmit the command to the server.

Is there any other way to test the connection before sending over the command to ensure that the connection is still active and the server is listening and will receive the command.

Connection is made in the following script:

If ConnectToServer1 = 1 Then
If Winsock1.State <> sckClosed And _
Winsock1.State <> sckConnected Then
Winsock1.Close
End If
If Winsock1.State = sckClosed Then
Winsock1.Connect
End If
'Report connection status
If Winsock1.State = sckConnected Then
Label1.Caption = "Connected to " & EncoderHost1 & ":" & EncoderPort1
Else
Label1.Caption = "Attempting to connect to Script Command Server: " _
& EncoderHost1 & ":" & EncoderPort1
End If
Else
Label1.Caption = "Not connected to Script Command Server: Running in stand-alone mode"
End If

Thanks so much for your help.

David

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