VS 2008 Closing The Asynchronous Socket?
Feb 6, 2011I have closed the client socket using client.close() but netstat command shows the same socket in time-wait state.Because of this I am unable to reuse the socket..
View 2 RepliesI have closed the client socket using client.close() but netstat command shows the same socket in time-wait state.Because of this I am unable to reuse the socket..
View 2 RepliesI am facing problem in asynchronous socket communication.
1)I wanted to perform connect(from client to server) operation on enter button and send the data whatever client want to send and disconnect from server. And again client should get connect to server whenever client wanted to send data. this is the mechanism.
i.e how to reuse the socket.
2)Again Server should able to send the data to client.
i'm creating an Asynchronous socket programming in vb.net. i've utilised the code from Asynchronous client and server code frtom the following links:m a new user so could post only one link fully)When I try to connect the for more than one client the second client always waits until the first clientcompletes the call. i want the clients to accept calls at the same time
View 1 RepliesI am attempted to write a small asynchronous socket library that I can use to create a client/server application. I can get all of the code to run fine if I leave it in the form, however if I try to move it out into its own class, I cannot figure out how to update the form with connection status, things like that. Below is code, shortened a bit just to make this easier to read and type.
[Code]....
There is actually more to that class, but I never get anything after the first message goes out. I'm not sure where to go from here. I've tried lots of different methods that I've found on the google searches, some from here, some not.
I have a Class called SocketSvr which handles an asynchronous socket server. It is called via the BackgroundWorker from my main form. Basically, I just want it to display my socket data information inside a textbox in the main form, and have a server start/stop button available on the main form to do those things.
Here is the code from Form1.vb:
Public Class Form1
Dim WithEvents Socketsvr As New SocketSvr
Private Sub ToggleServerButton_Click(ByVal sender As System.Object, _
[code]....
I am uncertain how to properly shut down requests from the client when the StopServer() function is run. In the code above, I place a cancellation queue for the background process. The funny thing is that once StopServer() is run, it will accept one more connection, then stop accepting thereafter.If I remove the following line from the code above:
listener.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1)
-- it crashes when I attempt to start the server a second time (complaining that I cannot reuse the socket, obviously) My guess is that I need to add something to the bw.CancellationPending call on the background worker?
In my small P2P Chat application I am listening on a port for messages and if some message arrives and pending, I am accepting it to a TcpClient and reading the data from the stream, writing back a "Received" response and closing it. This is in a loop with a sleep interval of 500 secs and runs in a separate thread. Is it a good practice to close the socket each time I receive and process a message or should I keep it alive till the chat box is closed on other side?
I am asking this because, when I do a "NETSTAT" on command line while chatting with someone, there is one entry per message that arrives locally. and many ports get to TIME_WAIT status, even if it is understood that they will be removed after 2 mins by the system.
my project was intially mandated to be done in c#.however a large contributor to the project wrote much of the business logic, which he knows well, in vb.net.How difficult would it be to convert the following c# code into vb.net.
[Code]...
Dim frm As Form
For Each frm In Forms
Set frm = Nothing
Next frm
The above code is what I used in VB6 to close all forms associated with my programs before my program closed. I have been searching for information on how to make sure all forms are closed when closing a VB2008 program.
I have seen info on using the Project Property Shutdown mode When startup form closes and I currently have this set.
Is this all that is really necessary? Will the garbage disposal close everything else to free up RAM?
Also, if I have several forms open and want to close all from the main form without closing each one individually, what is the best approach? Is there a collection like in VB6, go through the collection, compare it to the name of the main form and close it if it is not the main form?
Is webbrowser.navigate method is synchronous or asynchronous?
example:
dim ct as integer =0
dim counter as integer =0
ct+=1
wbb.navigate(""http://www.yahoo.com")
counter+=1
will counter get increased after firing webbrowser.document completed event?
I wrote a Socket Client which will send the Socket Server some data and get some response from Server. This process will be running once in every 2 seconds.
Now what I need to know is How we can identify the connection lost between Server and Client?
I need this to be implemented in the Client side. If there is no connection then Client should automatically close the connection. Once the connection with the server is available in the next attempt it should connect automatically.
Below is my code, but when i send the message thru client socket i receive Specified argument was out of the range of valid values. Parameter name: size
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim serverStream As NetworkStream = clientSocket.GetStream()
Dim outStream As Byte() = _
System.Text.Encoding.ASCII.GetBytes("0800822000000000000004000000000000000920092126012345001")
[CODE]...
Form1 is a mdi container. It has a bunch of forms that can load inside of it as mdi children. If I close each open form inside the form1, and then click the red X at the top right, application exits fine.If I click the red X without closing the forms inside I get: An unhandled exception of type 'System.CannotUnloadAppDomainException' occurred in mscorlib.dll
Additional information: Error while unloading appdomain. (Exception from HRESULT: 0x80131015) However I can break from it. How do I get the application to not show that error? What must I do to fix those inside forms or close when the red x is clicked?
how to do socket programming in VB. I'm using VB.NET 2008 and i'm a novice but with a reasonable understanding of programming so I want to learn by examples and understanding it in a novice/intermediate point of view. Essentially, I want to create a simple TCP or UDP client that can connect to an IP and port and retrieve the stream for parsing of content.
View 5 Repliesbefore you say something like "just search the forum for socket programing examples" I did and came up with things that were to complicated for me e.g multi threaded etc even a chat server that holds users names in a hash table i couldnt quite grasp so im asking if anyone can give me a few pointers maybe link me to a website that i havnt stumbled apon in my google seaches that contain infomation just about basic tcp server that recieves text strings no fancy users or anything like that.
View 2 Repliesi'm currently using my computer as host and client.. i ran the program and the console application for the server started.. but how will i be able to run the form application for the client? can VS run 2 programs at the same time?
View 6 Repliesmy goal is to control the incoming and outgoing packets to a game server, to alert when a game round finishes the main code is this:
Private Buffer(65535) As Byte
Private RawSocket As Socket
Public Event PacketReceived(ByVal PacketBuffer() As Byte)
[code]....
this code works perfectly with XP (you can read both incoming and outgoing packets to the game server)... with Vista the same code displays ONLY the incoming packets....
i got a program thats checks IP adresses and their host names by loking at the ip adress, but 1.- sometimes one ping responds but i get a socket this is the code hello = its the ip (it gets the ip from a list from a datagridview list)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim hello As String
Dim sum As Integer
[code]....
My code works fine under xp pro but not under windows 7 ?System.Net.Sockets.SocketException = {"The system detected an invalid pointer address in attempting to use a pointer argument in a call"}
View 1 RepliesI have the following code to close a form which is a child. The problem is that when it closes, it closes the MDI parent too.
Private Sub frmTransaction_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
If ListView1.Items.Count >= 1 Then
[Code]....
I am using Async socket class to handle HTTP data. The OnRecieve event handler looks like this:
Private Sub sck_onDataArrival(ByVal sData() As Byte, ByVal BytesTotal As Integer) Handles sck.onDataArrival
Try
Dim ms As New IO.MemoryStream(sData)
Dim returnImage As Image = Image.FromStream(ms)
Picturebox1.Image = returnImage
Catch ex As Exception
Debug.Print(ex.ToString)
End Try
End Sub
I realize this will not work because the byte array still contains the header information from the response from the server. How to strip this data without converting the byte array to a string. I need to strip the header response information and just be left with the image data and from there convert that data into a stream so the stream can be loaded into an image and displayed in my picturebox.
i need a little advice/help here. There is a particular scenario that is coming up and I am clueless as to how to go about it."I will soon have a lease line through which I will get realtime stock market data. This data will be available every second and it will contain prices of stocks. Now assume I am able to get that data on my local computer. How can I transmit data so that users can get that data through my software.
For e.g. assume it's 11 AM. Now if you select a stock e.g. Google, then my program should fetch data for google till 11 AM and also show new data every second or so with minimum lag. Something like a terminal where you see stock prices getting updates every second. In my case I need to get past data and show current data which get updated at short intervals."
Now I have a linux vps webserver which hosts my site. (I get one or two static ip free) What to do so that data goes from my local computer to my server and then my program (developed in vb.net) is able to get it and show it to end user. This whole system should such that its fast (real-time) and delay is minimum.
im trying to detect if the connection is still active upon trying to send or receive anything. Now I have checks in place if it's connected then it will send or receive however... it's saying it's connected when it is not connected... and therefore my program tries to send and receive and errors.
I am determining if it is ok to send and receive by using the Socket.Poll(-1, SelectMode.SelectWrite)
if it's true then im connected and data can be passed..This seems to always be true until I send something and it fails..How can I catch the socket not being connected before it fails upon sending or receiving?
I realize this is a broad question, but how do I recieve / send packets. I know what packets I need to send and what Im going to recieve, but I dont know how to send / recieve them.
View 8 RepliesI have been working on recoding a VB6 client/server application of mine and have run into a bit of an issue with storing the players location on the tile map which means I will need to rework the way I am storing the user connections. In my VB6 application I would store the user's numeric index/socket number/whatever you'd like to call it as the Key, however, in VB 2008 I can't seem to find where, or if, the numeric index is stored. If this isn't possible then does anyone have an example of how they store user connections using some numeric index as the key of a hashtable?
View 6 Repliesi try to transfer packets from the PC to the Mobile phone~ my PC is act as a Server and Mobile as a Client. My Mobile is successfully connect to my PC, but when i try to pass a packets from Mobile, it went failed without any error. The Server didn't receive any packets from Mobile. i had test my code on PC to PC and it's work fine. Anyone have this kind of experience?
View 3 RepliesI have been developing an async socket connection server and client program. I have been testing it, and noticed that if I connect to the server from my client and then disconnect. Upon reconnecting I am on a different port(local IP still). This is fine, however when I go to send a message, and the server trys to update all the clients, it eventually hits clients that do not exist anymore. I get the SocketException 10054, and upon connecting/disconnecting enough, it no longer works at all. My question is how do I clear out these no longer useful sockets from the server? I am doing currentsocket.Shutdown(SocketShutDown.Both); and then a currentsocket.Close(); after that. When a user disconnects.
[Code]...
Im trying to set up some error catching. So if the process errors out in the middle of reading a text file using a StreamReader, the file stays opened. What is a good way for me to close that file after the error? For example, here's some
[Code]...
looking for an easy way to close Adobe Reader from VB if it's open.
View 1 RepliesI'm running a program, the first form is a login form. If you pass this i Hde form1 and show form2.When i'm click the x in the top right hand corner my form goes away but in my processes (task manager) it's still there. why?
View 9 RepliesI didn't code for a complete year. Don't ask me why. well I guess I lost 90% of my vb skills, I hope they'll get back eventually.i'm writing a console program, but it closes after a second it opens.I want it open all the time.
View 2 Replies