How To Connect Socket To Server Rapidly
Jan 23, 2011
I'm using sockets to connect to servers and for some strange reason I can't identify, the socket is taking several seconds (5 maybe 6) seconds to connect when using an IP whereas is instant when using a hostname. Here is my code to connect:[code...]
In the above code, server of course is a string. I've tested this with a friend and she's experiencing the same issue and I'd like to get around it as it's sort of annoying..While debugging GetHostEntry is the line that seems to take forever when using an IP.
View 1 Replies
ADVERTISEMENT
May 21, 2011
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.
View 1 Replies
Oct 16, 2009
I'm trying to use a socket to connect a TCP stream. The socket connects no problem if the endpoint has a valid IP associated to it. If I give it an invalid one, the Connect method will sit and block (I want it to) for 10-20 seconds before telling me the remote host timed out. Is there a timeout property I can set so I don't have to wait that long for the connect method? Or is there another way of doing it that does implement a timeout?
View 3 Replies
Apr 9, 2012
I started to setup a Server and a Client for personal purpose. When I try to connect the Server by a computer inside a shared network, with local IPs, works but when I try to connect an external IP, doesn't work.[code]
View 3 Replies
Oct 2, 2011
i need to check if a port is open, apparently i can't ping ports so i need to use sockets, and it seems that there is no option for timeout on the connecting... how can i put a timeout on connect?
View 3 Replies
Oct 26, 2011
I made a simple TCP server (I've found the example on the web) in VB to receive data from about 40 TCP clients.The clients are not synchronized but sends data about every 18 minutes; the problem is sometimes several clients sends data at the same moment, so I can't receive data.I also made a second program that reads the data (server program writes data on a file, read from the second program) scheduled.
My question is this: I've seen on the web examples about Multithreaded Server Socket Program, so I suppose this could manage my 40 clients (but now the clients are syncronized and send data at the same time in client mode) or is better get data (I have a central client that asks data to all 40 devices in server mode)?
Second question: can I make a single program where I run both TCP client and TCP server at the same time?
View 1 Replies
Nov 29, 2011
Read this: [URL]. Now the question: I want the client will connect to web server (or web hosting).
View 8 Replies
Jun 7, 2010
i took this code from another example, it works fine but it a windows console application.i took the code into a windows form app but it looks like i have to change somethingto start, it says client is not defined, so what should i use?lient.startClient(clientSocket, Convert.ToString(counter))
Dim serverSocket As New TcpListener(8888)
Dim clientSocket As TcpClient
Dim counter As Integer
[code].....
View 4 Replies
Dec 16, 2008
transfer this from a Console app to a WinForms app? I'm still new to this and I want to build on top of this once I get more acquainted with VB.net. I don't know if this may be helpful, but I'm using Visual Studio 2008 (not express).
The Server Code I Found Online:
Imports System.Net.Sockets
Imports System.Text
Imports System.IO
Imports System.Net
[code].....
View 1 Replies
Aug 3, 2011
i'm creating an IRC server and I already have a few base classes complete like logging and Config. I was about to start with programming the socket class(es) when I realized that I have no idea how to make such a complicated socket system. I do not under any circumstance want to use any other code than my own since that would not help me learn sockets. I am familiar with a single connection socket system like most tutorials use.
[Code]...
View 2 Replies
Jul 14, 2009
how to access client side activity i.e. which client is connected and which computer connected at the same time from server.
View 1 Replies
Apr 21, 2008
I am new to socket communication. I found a few samples on the web and I managed to make my own host-client communication but i wanted to go a bit further and connect to port 80 of a server and it was just a disaster! First of all I know I can just use the functions that vb has itself but I want to make my own connections ... I have got some reasons I need this one! Do I really have to make them "connect" or just somehow without connecting I get the data? So I'm stack at the point that the connection is made ... it refuses to connect.
View 7 Replies
Nov 24, 2011
I have the following code in my Server Form:
Imports System.Net, System.Net.Sockets
Public Class ServerForm
Private serverSocket As Socket
Private clientSocket As Socket
[code]....
for the first time, when I click on Connect, it is going to connect to server as well and also it works if you click on the disconnect. for the second time if you click on the Connect button, it gets connected but the disconnect button is not working.
View 9 Replies
Mar 11, 2010
I have an application to make a server and clients to read/ send text to it but I want a program I can run from a remote computer that you enter the ip and port and it crashes the server.
View 2 Replies
Apr 7, 2010
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.
View 8 Replies
Feb 10, 2010
I planing to develop an application which can connect any remote server and pick the configuration information from server and show it in my desktop.
View 4 Replies
Dec 7, 2010
How can I write a connection string? I has four different computer that can be connect via ethernet.How can I maintain a inserting data if to computer insert on same table at a single time..??
View 1 Replies
Apr 23, 2012
For almost a week I am reading and trying to find a solution for checking connection state using a TCP Client (using socket class) In my scenario I have a TCP Client that is connected to a server (it is not controlled by me) and i want that from time to time to check the connection state, and reconnect if necessary.I have read a lot of information on the internet but i did not find a suitable solution.Briefly, these are the methods that i have found on the internet and try to implement.But unfortunatelly, i have found some scenarios where the TCP Server is closed and the TCP Client is still saying Connected 1.Example from MSDN
[code]...
View 1 Replies
Sep 13, 2011
I want both the client and server to write and read resp. at a constant rate (which can be configured on the GUI of the client) to the buffer.I am able to send from the client at 150 bytes per packet Now, I should be able to read also at 150 bytes per packet on the server too Since, both are connected through a socket, can we retrieve the socket params (set on the client size, like 150 here) from the server end, using the tcpServer object.Or is it must to send an initial setup packet which tells about these client params and so accordingly the server can continue?
View 1 Replies
Apr 21, 2012
So I have set up a basic client/server connection and I am trying to send a message to one another on connection, I got the client to receive the message from the server, but the server doesn't recieve the clients message. Here is my current code for reading the sent data from the client:
ServerThread.socket = new ServerSocket(5556);
Socket client = ServerThread.socket.accept();
DataInputStream in = new DataInputStream
[code]....
View 2 Replies
Jan 12, 2012
I created a server-client application using the asynchronous socket. I found the problem when closing a socket on the server, applications so closed. The procedure that I do to close the socket server is:
Terminate the listening thread. Close the client socket is still connected to the server. Close the server socket.
How to prevent the application is closed, when I close the server socket?
Protected Friend Sub CloseServerSocket(ByVal IPAddress As IPAddress, ByVal socketPort As Integer)
' Terminate the listening thread.
[Code].....
View 1 Replies
Apr 20, 2012
I have a TCP Socket Client (using the Socket Class) that is connected to a simple TCP socket server (just for testing)I have this code snippet :
Dim aSocket as Socket
While aSocket.Connected = True
byteRead = aSocket.Receive(dataByte) 'number of bytes
[code].....
View 1 Replies
Nov 24, 2009
Please excuse my choice of wording and/or mixup of terms, I am a dummy when it comes to socket programming. I am trying to connect to a TCP server, write a message and process a response. I use the following code:
Dim tcpClient As Sockets.TcpClient = New TcpClient()
tcpClient.Connect(hostname, 9080)
Dim networkStream As NetworkStream = tcpClient.GetStream()
[code].....
View 1 Replies
Aug 17, 2011
I am making a java chat server, and a guy was able to connect to it no problem (however, he logged off for the night before I ran into any problems, so I couldn't see what he did). Here is my code on the VB form:
[Code]....
View 5 Replies
Jun 14, 2012
I am Working on Teghax Component.Using This Component we want to find out Block title attribute of dwg file in a client server socket application.
1> We get Block title attributes properly of dwg file in windows application form using the getattribute function().
2> We get Block title Attributes properly in that way:-We take a class library where we take a class.in this class we use getattribute function().Then We access the particular class from another project
But when we use the same class(Keep same structure) in client server socket program.Then it gives an exception.i.e ,"Spaicfied cast is not valid"I am Not getting any reply form teghax developer..I attached exception screen sort.Give me Suggestion How to solve this Exception
Code given Bellow :
Public Function Get_DwgFileAttribute(ByVal Sender As ClsTcpConnection, ByVal msgTag As Byte, ByVal message As String) As String
Dictionary = GetHashtable(message)
Dim varfilepath As String = CStr(Dictionary.Item("filePath"))
[code]....
View 1 Replies
Nov 23, 2011
I would like to make a multi-socket TCP server (to accept multiple clients at the same time).I'm working with Visual Studio 2005 Express, maybe that's why files on CodeBank don't work..I found on the web an example about MultiThreaded Server Socket programming, but this is done for "Console application" in this way:
[Code]...
View 7 Replies
Jun 24, 2010
I am working on a chat client and server, and so far it works well, but when I close the client, the server throws an exception because it continues to try to do processes on the disconnected client. I have tried adding clientSocket.Close() in various places throughout the client and server with no luck. Does someone know how to add the disconnect code to either the server or client with this code?Server:
Imports System.Net.Sockets
Imports System.Text
Module Module1
[code].....
View 5 Replies
Jun 30, 2010
I wanted to know what are the risks of opening up a socket server on a specified port? Right now I have it limited to only accept requests from 1 specific IP to that port and all the other ones get rejected (using the windows firewall), is there a way to implement an authentication or anything else so I can allow it to be accessed from any IP worldwide yet have it secured?
View 1 Replies
Mar 21, 2012
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?
View 1 Replies
Feb 2, 2011
I 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.
View 5 Replies