Hi,
Experimenting with sockets, and I think I got it half working. I have the
following code:
Private Sub socket_receive( ByVal sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Activate d
Dim bytesRec As Integer
Dim i As Integer = 0
Dim data1 As Net.Sockets.Soc ket = cidServer.Accep t() 'this line is
causing program to hang
bytesRec = data1.Receive(b ytes)
dataString = System.Text.Enc oding.Default.G etString(bytes, 0,
bytesRec)
If dataString = "f" Then
MsgBox("Du hast f gedruckt")
data1.Disconnec t(True)
Else
MsgBox("Du hast f nicht gedruckt")
data1.Disconnec t(True)
End If
End Sub
Basically, what I have discovered is that once this section of code has
loaded, the rest of the program will halt because it is expecting data from
the line:
Dim data1 As Net.Sockets.Soc ket = cidServer.Accep t()
I have sockets working properly, so if I go and telnet localhost <port#> and
then just enter the key 'f' a message box will pop up telling me that I hit
the letter 'f', or not respectively. After this event the program will
resume working, since it is finished with "Dim data1 As Net.Sockets.Soc ket =
cidServer.Accep t()". This is sort of like scanf() in C where the program
stops and waits for input.
My question is how would I allow the program to run while listen to the
socket at the same time? I.e. I can use the program and I can telnet
localhost <port#> without having a hung program? I was thinking if there
might be an event handler that could activate my socket_receive( ) method if
a user telnets in and enters data.
-Thanks 3 1499
You can listen to the socket on a different thread... What do is spawn
thread from the UI application and then in that thread you can create and
listen to sockets.. Everytime you want to notify the main UI thread, you can
send a notification using events...
How you can do the above really depends whether you are with VS.NET 2003
(1.1) or VS.NET 2005(2.0)?
VJ
"derSchweiz " <ke***@keine.de > wrote in message
news:Rhf0g.2624 1$P01.12050@pd7 tw3no... Hi,
Experimenting with sockets, and I think I got it half working. I have the following code:
Private Sub socket_receive( ByVal sender As Object, ByVal e As System.EventArg s) Handles MyBase.Activate d Dim bytesRec As Integer Dim i As Integer = 0 Dim data1 As Net.Sockets.Soc ket = cidServer.Accep t() 'this line is causing program to hang
bytesRec = data1.Receive(b ytes)
dataString = System.Text.Enc oding.Default.G etString(bytes, 0, bytesRec)
If dataString = "f" Then MsgBox("Du hast f gedruckt") data1.Disconnec t(True) Else MsgBox("Du hast f nicht gedruckt") data1.Disconnec t(True) End If End Sub
Basically, what I have discovered is that once this section of code has loaded, the rest of the program will halt because it is expecting data from the line: Dim data1 As Net.Sockets.Soc ket = cidServer.Accep t()
I have sockets working properly, so if I go and telnet localhost <port#> and then just enter the key 'f' a message box will pop up telling me that I hit the letter 'f', or not respectively. After this event the program will resume working, since it is finished with "Dim data1 As Net.Sockets.Soc ket = cidServer.Accep t()". This is sort of like scanf() in C where the program stops and waits for input.
My question is how would I allow the program to run while listen to the socket at the same time? I.e. I can use the program and I can telnet localhost <port#> without having a hung program? I was thinking if there might be an event handler that could activate my socket_receive( ) method if a user telnets in and enters data.
-Thanks
Great!
Found a good article here- straight and to the point: http://searchvb.techtarget.com/vsnet...293037,00.html
Its working now.
"VJ" <so*****@ms.com > schrieb im Newsbeitrag
news:eA******** ******@TK2MSFTN GP05.phx.gbl... You can listen to the socket on a different thread... What do is spawn thread from the UI application and then in that thread you can create and listen to sockets.. Everytime you want to notify the main UI thread, you can send a notification using events...
How you can do the above really depends whether you are with VS.NET 2003 (1.1) or VS.NET 2005(2.0)?
VJ
"derSchweiz " <ke***@keine.de > wrote in message news:Rhf0g.2624 1$P01.12050@pd7 tw3no... Hi,
Experimenting with sockets, and I think I got it half working. I have the following code:
Private Sub socket_receive( ByVal sender As Object, ByVal e As System.EventArg s) Handles MyBase.Activate d Dim bytesRec As Integer Dim i As Integer = 0 Dim data1 As Net.Sockets.Soc ket = cidServer.Accep t() 'this line is causing program to hang
bytesRec = data1.Receive(b ytes)
dataString = System.Text.Enc oding.Default.G etString(bytes, 0, bytesRec)
If dataString = "f" Then MsgBox("Du hast f gedruckt") data1.Disconnec t(True) Else MsgBox("Du hast f nicht gedruckt") data1.Disconnec t(True) End If End Sub
Basically, what I have discovered is that once this section of code has loaded, the rest of the program will halt because it is expecting data from the line: Dim data1 As Net.Sockets.Soc ket = cidServer.Accep t()
I have sockets working properly, so if I go and telnet localhost <port#> and then just enter the key 'f' a message box will pop up telling me that I hit the letter 'f', or not respectively. After this event the program will resume working, since it is finished with "Dim data1 As Net.Sockets.Soc ket = cidServer.Accep t()". This is sort of like scanf() in C where the program stops and waits for input.
My question is how would I allow the program to run while listen to the socket at the same time? I.e. I can use the program and I can telnet localhost <port#> without having a hung program? I was thinking if there might be an event handler that could activate my socket_receive( ) method if a user telnets in and enters data.
-Thanks
Great!!
VJ
"derSchweiz " <ke***@keine.de > wrote in message
news:Wul0g.2681 3$P01.3099@pd7t w3no... Great! Found a good article here- straight and to the point: http://searchvb.techtarget.com/vsnet...293037,00.html
Its working now.
"VJ" <so*****@ms.com > schrieb im Newsbeitrag news:eA******** ******@TK2MSFTN GP05.phx.gbl... You can listen to the socket on a different thread... What do is spawn thread from the UI application and then in that thread you can create and listen to sockets.. Everytime you want to notify the main UI thread, you can send a notification using events...
How you can do the above really depends whether you are with VS.NET 2003 (1.1) or VS.NET 2005(2.0)?
VJ
"derSchweiz " <ke***@keine.de > wrote in message news:Rhf0g.2624 1$P01.12050@pd7 tw3no... Hi,
Experimenting with sockets, and I think I got it half working. I have the following code:
Private Sub socket_receive( ByVal sender As Object, ByVal e As System.EventArg s) Handles MyBase.Activate d Dim bytesRec As Integer Dim i As Integer = 0 Dim data1 As Net.Sockets.Soc ket = cidServer.Accep t() 'this line is causing program to hang
bytesRec = data1.Receive(b ytes)
dataString = System.Text.Enc oding.Default.G etString(bytes, 0, bytesRec)
If dataString = "f" Then MsgBox("Du hast f gedruckt") data1.Disconnec t(True) Else MsgBox("Du hast f nicht gedruckt") data1.Disconnec t(True) End If End Sub
Basically, what I have discovered is that once this section of code has loaded, the rest of the program will halt because it is expecting data from the line: Dim data1 As Net.Sockets.Soc ket = cidServer.Accep t()
I have sockets working properly, so if I go and telnet localhost <port#> and then just enter the key 'f' a message box will pop up telling me that I hit the letter 'f', or not respectively. After this event the program will resume working, since it is finished with "Dim data1 As Net.Sockets.Soc ket = cidServer.Accep t()". This is sort of like scanf() in C where the program stops and waits for input.
My question is how would I allow the program to run while listen to the socket at the same time? I.e. I can use the program and I can telnet localhost <port#> without having a hung program? I was thinking if there might be an event handler that could activate my socket_receive( ) method if a user telnets in and enters data.
-Thanks
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Leon Mergen |
last post by:
Hello,
I'm currently in the process of implementing a web server. I've
currently applied the Reactor pattern an Half Sync/Half Async pattern
for accepting client connections and creating a thread pool.
Now, I'm using the select() mechanism to determine which sockets are
ready to be read/written to. When an activity occurs, all the 'active'
socket handles are sent to a queue. These are picked up by a thread of a
thread pool.
|
by: Rookie |
last post by:
Hi,
I was writing a simple program using sockets. The program is supposed to be
a TCP server that receives a string sent by the client. For this purpose I
defined a char array called readString which was initially defined as
readString. The program worked fine. I then increased the array size to
readString and the accept socket call started giving an error
(errno=14;EFAULT). This gave me the impression that the clientAddr structure
was...
|
by: DarkLotus |
last post by:
Code:
--------------------
BOOL IsIPRight(char *ip)
{
unsigned long TheIP;
TheIP ip;
TheIP = inet_addr("66.55.44.33");
|
by: Dan Holmes |
last post by:
The first tim ethis app is run it works just fine as well as every
restart. What i can't figure is how to get it to accept a connection
after the first one.
This is a console app but i don't think that matters.
using SNS = System.Net.Sockets;
|
by: opi |
last post by:
My blocking TCP server hangs in the Accept method when the client
software sometimes gets an error. Are there any ways to stop this
blocking in the Accept method so I dont have to restart the server?
I would rather not use threading or non-blocking sockets.
Using VB.Net 2005.
| |
by: billiejoex |
last post by:
Hi,
I'm writing a small asyncore-based server application serving a lot of
clients. When I have to handle more than 1021 client simoultaneously
the 'binded' socket object raises an error:
connections: 1018
connections: 1019
connections: 1020
connections: 1021
|
by: 7stud |
last post by:
I have the following two identical clients
#test1.py:-----------
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = 'localhost'
port = 5052 #server port
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |