|
You don't - if you didn't get an answer you're happy with, then you probably won't get a better one this time around
|
|
|
|
|
|
And what if I started a discussion, and made some progress since and want to ask further related question? what would you suggest?
|
|
|
|
|
If you reply to someone, they'll get an email notifying them of the reply.
If you've got a whole new question to ask, then it's fine to post this as a new thread - it's mostly protection against the idiots who post stupid / impossible questions, and would just constantly bump their thread to the top if given the chance (they already try reposting the same question over and over, but that's easier to ignore)
|
|
|
|
|
By bouncing do you mean stopping a service/thread and then restarting it?
If no, then you need to explain what bounce is.
If yes, then if you're momentarily halting the thread, like pressing the pause button, then you could use Thread.Sleep()/Interrupt()/Join(), more on that here: http://msdn.microsoft.com/en-us/library/system.threading.thread_members.aspx[^]
If you mean pausing the application mid activity and then closing it and once the application is run again you would expect the system to pick up from where you left off, you'll need to save state and that would at the least require serialization.
|
|
|
|
|
I think he means "bump" a thread as in a forum post. As in bring it back to the top. As in the thing we hate and pour scorn on whoever does it.
|
|
|
|
|
Ah!
<Padawan mode on>
I'd like to see him try
<\Padawan mode on>
|
|
|
|
|
My device has 4 inputed of capture intend that my application communicates with the device,
to visualize the 4 videos and to record.
Alex(alex_xso@hotmail.com)
|
|
|
|
|
Alex_xso wrote: My device has 4 inputed of capture intend that my application communicates with the device,
to visualize the 4 videos and to record.
OK, so where is the problem?
Also, do you have drivers? API to deal with the video capture device?
|
|
|
|
|
|
I have developed a simple client/server app which echoes whatever text the clients sends to the server.
Currently, it echoes text only to one client, which has send the text, but I want it to send to all the clients connected.
The problem is that when one client writes to the server after that the client waits for receiving and as soon it has received the echo it starts writing to the server, so if some other client sends to the server, and the server echoes back to all the clients, only those will receive the message which are waiting for reading, but none are except the client which has send the message to the server.
So how to overcome this?
Btw, it is a console application, is it possible to do in it?
I guess I explained it correctly. If not, then please ask again
modified on Monday, January 26, 2009 9:59 AM
|
|
|
|
|
It sounds like you're trying to emulate a group chat/IM session.
You're going to need to register all the users who "log" on to your server and are interested in the echo. The Observer pattern is precisely what you are looking for: http://www.dofactory.com/Patterns/PatternObserver.aspx[^] and http://en.wikipedia.org/wiki/Observer_pattern[^]
After reading that you should have a clue of what you ought to do but in plain English what you're doing is that you're making a list of all the registrants and instead of echoing to one, you're broadcasting the echo to each and everyone in the list.
Post back if you need more help.
|
|
|
|
|
Well, whenever a user is connected I store its connection and username in a hashtable,
and when the server receives a message, I create a for loop and gets everyone's specific stream and then send the message to them. But at that time the clients are waiting for the input, rather than reading what the server has send. Only that client reads who have send the message to the server.
Do you want me to post the code?
Heres the code for the server
using System;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Threading;
using System.Collections;
using System.Text;
public class ClientHandler
{
public TcpClient clientSocket;
public void RunClient()
{
StreamReader readerStream = new StreamReader(clientSocket.GetStream());
NetworkStream writerStream = clientSocket.GetStream();
string returnData = readerStream.ReadLine();
string userName = returnData;
Console.WriteLine("Welcome " + userName + " to the Server");
while (true)
{
returnData = readerStream.ReadLine();
if (returnData.IndexOf("QUIT") > −1)
{
Console.WriteLine("Bye Bye " + userName);
break;
}
Console.WriteLine(userName + ": " + returnData);
returnData += "\r\n";
byte[] dataWrite = Encoding.ASCII.GetBytes(returnData)
writerStream.Write(dataWrite,0,dataWrite.Length);
}
clientSocket.Close();
}
}
public class EchoServer
{
const int ECHO_PORT = 8080;
public static void Main(string [] arg)
{
try
{
TcpListener clientListener = new TcpListener(ECHO_PORT);
clientListener.Start();
Console.WriteLine("Waiting for connections…");
while (true)
{
TcpClient client = clientListener.AcceptTcpClient();
ClientHandler cHandler = new ClientHandler();
cHandler.clientSocket = client;
Thread clientThread = new Thread(new ThreadStart(cHandler.RunClient));
clientThread.Start();
}
clientListener.Stop();
}
catch(Exception exp)
{
Console.WriteLine("Exception: " + exp);
}
}
}
and heres the code for client
using System;
using System.Net;
using System.IO;
using System.Net.Sockets;
using System.Text;
public class EchoClient
{
const int ECHO_PORT = 8080;
public static void Main(string [] arg)
{
Console.Write("Your UserName:");
string userName = Console.ReadLine();
Console.WriteLine("-----Logged In----->");
try
{
TcpClient eClient = new TcpClient("127.0.0.1", ECHO_PORT);
StreamReader readerStream = new StreamReader(eClient.GetStream());
NetworkStream writerStream = eClient.GetStream();
string dataToSend;
dataToSend = userName;
dataToSend += "\r\n";
byte[] data = Encoding.ASCII.GetBytes(dataToSend);
writerStream.Write(data,0,data.Length);
while(true)
{
Console.Write(userName + ":");
dataToSend = Console.ReadLine();
dataToSend += "\r\n";
data = Encoding.ASCII.GetBytes(dataToSend);
writerStream.Write(data, 0, data.Length);
if (dataToSend.IndexOf("QUIT") > −1)
break;
string returnData;
returnData = readerStream.ReadLine();
Console.WriteLine("Server: " + returnData);
}
eClient.Close();
}
catch(Exception exp)
{
Console.WriteLine("Exception: " + exp);
}
}
}
|
|
|
|
|
Three things:
1. Did you read the literature I posted? It'll really help you
2. Why are you using a Hashtable?
3. cHandler.clientSocket = client; See this? You're only ever responding to one and one client at any time, and if you don't mind me saying it, you're doing a bad job of it. Read the literature, it'll show you a really good way of doing things.
|
|
|
|
|
sorry I posted the old code
heres the modified one where i send messages to all.
btw i'm going to read the article you given
while you tell me if the code is correct or not
void RunClient()
{
StreamReader readerStream = new StreamReader(clientSocket.GetStream());
NetworkStream writerStream = clientSocket.GetStream();
string returnData = readerStream.ReadLine();
string userName = returnData;
users.Add(userName, clientSocket);
Console.WriteLine("Welcome " + userName + " to the Server");
while (true)
{
returnData = readerStream.ReadLine();
String tempData = returnData.ToLower();
if (tempData.IndexOf("quit") > -1)
{
Console.WriteLine("Bye Bye " + userName);
break;
}
Console.WriteLine(userName + ": " + returnData);
returnData += "\r\n";
byte[] dataWrite = Encoding.ASCII.GetBytes(returnData);
TcpClient[] tcpClients = new TcpClient[users.Count];
users.Values.CopyTo(tcpClients, 0);
for (int i = 0; i < tcpClients.Length; i++)
{
NetworkStream tempWriteStream = tcpClients[i].GetStream();
tempWriteStream.Write(dataWrite, 0, dataWrite.Length);
tempWriteStream = null;
}
}
clientSocket.Close();
}
modified on Monday, January 26, 2009 10:43 AM
|
|
|
|
|
OK, this is in the wrong forum now.
|
|
|
|
|
no, i changed the code
|
|
|
|
|
You did, from C# to C++/CLI which makes it in the wrong forum
|
|
|
|
|
it is C#
|
|
|
|
|
I know how to "create" a Service application.
I know what to write in the main() function.
I know how to add an EventLog (or other components) to the service.
I know how to define what happens when the service starts, stops or resumes.
What I want to know is this...
I want my Windows Service to run an Indexer function.
Where do I add this code in the Service application?
|
|
|
|
|
well i suppose it depends on when you want to call the function
|
|
|
|
|
In a thread that is instantiated from the Start() method.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
hi men
how can I make validation to accept specific input
such as in my text box Only email is valid input
aaa..@dddd.com
like that
|
|
|
|
|
well one option would be to check for a '@' character in the textbox.Text string, then see if there is atleast one '.' character after the '@' character.
something like:
string text = TextBox1.Text;
string[] split = text.split('@');
if(split.length == 1)
{
if(split[1].Contains('.'))
}
|
|
|
|
|
musefan wrote: well one option would be to check for a '@' character in the textbox.Text string, then see if there is atleast one '.' character after the '@' character.
Have you ever heard of Regular Expressions?
In fact, Regular Expression validators(as the name suggest) can do this with lot ease.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|