I have an app that uses the standard Socket Client code. I send it a
message to call a function and it receives the message, debugs through
the function, but the function doesn't actually fire. Anyone have a
clue? Here is the code:
public void DoRead(IAsyncResult ar)
{
int BytesRead;
string strMessage;
try
{
// Finish asynchronous read into readBuffer and return number of
bytes read.
BytesRead = client.GetStream().EndRead(ar);
if (BytesRead < 1)
{
// if no bytes were read server has close. Disable input window.
MarkAsDisconnected();
return;
}
// Convert the byte array the message was saved into, minus two for
the
// Chr(13) and Chr(10)
strMessage = Encoding.ASCII.GetString(readBuffer, 0, BytesRead -
2);
ProcessCommands(strMessage);
///
///
// Start a new asynchronous read into readBuffer.
client.GetStream().BeginRead(readBuffer, 0, READ_BUFFER_SIZE, new
AsyncCallback(DoRead), null);
ThreadFunction1 thr1 = new ThreadFunction1();
Thread tid1 = new Thread(new ThreadStart(thr1.getOneAtATime ) );
}
catch( Exception e)
{
MarkAsDisconnected();
}
}
the function that I need to run is getOneAtATime. The function works
with a button click...but will not work outside this thread, inside
this thread or even if i call the button click "button.performclick()"
Help is appreciated.
Thanks,
Trint 2 1576
"trint" <tr***********@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com... I have an app that uses the standard Socket Client code. I send it a message to call a function and it receives the message, debugs through the function, but the function doesn't actually fire. Anyone have a clue? Here is the code:
public void DoRead(IAsyncResult ar) { int BytesRead; string strMessage;
try { // Finish asynchronous read into readBuffer and return number of bytes read. BytesRead = client.GetStream().EndRead(ar); if (BytesRead < 1) { // if no bytes were read server has close. Disable input window. MarkAsDisconnected(); return; } // Convert the byte array the message was saved into, minus two for the // Chr(13) and Chr(10) strMessage = Encoding.ASCII.GetString(readBuffer, 0, BytesRead - 2); ProcessCommands(strMessage); ///
/// // Start a new asynchronous read into readBuffer. client.GetStream().BeginRead(readBuffer, 0, READ_BUFFER_SIZE, new AsyncCallback(DoRead), null);
ThreadFunction1 thr1 = new ThreadFunction1(); Thread tid1 = new Thread(new ThreadStart(thr1.getOneAtATime ) ); } catch( Exception e) { MarkAsDisconnected(); } }
the function that I need to run is getOneAtATime. The function works with a button click...but will not work outside this thread, inside this thread or even if i call the button click "button.performclick()" Help is appreciated. Thanks, Trint
Missing a tid1.Start() ?
Willy.
Willy,
You are correct...but after I fixed that, it still didn't execute
although the debugger steps through the function. Even if it isn't in
a thread, it doesn't work. It works when "button_clicked". Or any
other direct event to the Client program except a read from the server.
This phenomenon happens "or doesn't happen" when attempting to execute
it from the Socket Server:
Socket Server (message to client) ----tcp/ip-----> Socket Client
(message received) "nothing".
Thanks,
Trint This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: anuradha.k.r |
last post by:
hi,
i am writing a socket program in python,both client side and server
side.I've written the client side which is working perfectly
fine(checked it against server program written in C).but as for...
|
by: John Sheppard |
last post by:
Thanks to everyone that responded to my previous Socket Programming question. Now I have run into some behavior that I don't quite understand.
Programming environment. VS.NET 2003, C#, Windows...
|
by: Chris Tanger |
last post by:
Context:
C#
System.Net.Sockets
Socket created with constructor prarmeters Internetwork, Stream and TCP
everything else is left at the default parameters and options except linger
may be changed...
|
by: Rene Sørensen |
last post by:
We are 4 students working on a assignment, that our teacher gave use,
normally we do this is C++, but the 4 of us, use C# more often that
C++ so…
We made a small games called reversi, now our job...
|
by: Colin |
last post by:
I'm writing a little console socket server but I'm having some
difficulty. Can I ask your advice - where is the best place to get
some help on that topic? It would be nice if some people who knew...
| |
by: coloradowebdev |
last post by:
i am working on basically a proxy server that handles requests via remoting
from clients and executes transactions against a third-party server via TCP.
the remoting site works like a champ. my...
|
by: zxo102 |
last post by:
Hi,
I am doing a small project using socket server and thread in python.
This is first time for me to use socket and thread things.
Here is my case. I have 20 socket clients. Each client send a...
|
by: keksy |
last post by:
Hi every1,
I am writing a small client/server application and in it I want to
send an image asynchronous from the client to the server through a TCP
socket. I found an example code on the MSDN...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
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,...
| |
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
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...
|
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 ...
| |