|
So this is probably a dumb question, but I'm new to network programming and just trying to figure out all the details...
I've been messing around with settings up a Server/Client application, using the TcpClient and TcpListener objects. These are nice and easy, but how do I communicate outside of my local network? For instance, how do I start a server on a computer on my network with a router assigned address (ie. 192.168.X.XXX) and have someone else connect to it from another location? I can't just give them the 192.168.X.XXX address to type in for their TcpClient... so how do I establish a connection, or can I? Do I just need to have a server that isn't connected to the internet by a router?
Basically I want to so something similar to what a game server would do... start up a game and act as the server, have people connect to it, transfer some data, then shut everything down. Is there just another way to obtain an address that will properly resolve to my server if it's on a router?
Thanks in advance...
|
|
|
|
|
You must use port forwarding in the router. Just set port forwarding to IP 192.168.X.XXX and enter the port number you want (intern and extern).
|
|
|
|
|
Hey thanks... that was the missing piece! Direct and helpful. Now I know...
|
|
|
|
|
Has anyone done this with C# before?
|
|
|
|
|
devfendar wrote: Has anyone done this with C# before?
Replicate what?
|
|
|
|
|
What do you mean here ?
If you're asking about creating a copy of the existing object - have a look at the IClonable interface.
Best regards,
-----------
Igor Sukhovhttp://sukhov.net
|
|
|
|
|
|
I found a quine by Peter Gfader[^], that I of course had to improve upon...
using System; class MainApp { public static void Main() { char q=(char)34;string var=System.Text.Encoding.ASCII.GetString(new byte[]{115,116,114,105,110,103,32,98,61});char s=';';string a="using System; class MainApp { public static void Main() { char q=(char)34;string var=System.Text.Encoding.ASCII.GetString(new byte[]{115,116,114,105,110,103,32,98,61});char s=';';string a=";string b="Console.WriteLine(a+q+a+q+s+var+q+b+q+s+b); } }";Console.WriteLine(a+q+a+q+s+var+q+b+q+s+b); } }
---
b { font-weight: normal; }
|
|
|
|
|
public class MyClass : ICloneable
{
public object Clone()
{
return (object)this;
}
}
|
|
|
|
|
hI,
I have a web page in which i am generating all the controls dynamically .I have a place holder(also dynamically generated)in webform1 into which i am pushing all the All the generated controls .
Now i want ato inherit this page into webform2 .What i tried was
public class Webform2 : webform1
in webform class i have a ftion
public void look()
{
// Response.Write("look");
PlaceHolder pl = new PlaceHolder();
TextBox tb;
tb = new TextBox();
tb.Text = "adarsh";
tb.Visible = true;
tb.Width = Unit.Percentage(20);
tb.Height = Unit.Percentage(20);
pl.Controls.Add(tb);
this.form1.Controls.Add(pl);
}
}
in webform2 class i call page load event i call this ftion look .But it gives a runtime exception saying in line this.form1.Controls.Add(pl); object reference not set to an instance of an object.Why is this and pls suggest any solution for this.
-- modified at 1:54 Monday 3rd July, 2006
|
|
|
|
|
i had barcode but please help me to use it in my project
i dont how to use it which control would help me to use it and and how how to use what it read
|
|
|
|
|
omar el halwagy wrote: i had barcode but please help me to use it in my project
i dont how to use it which control would help me to use it and and how how to use what it read
You had it and now you don't? Don't quite understand your question. If you're looking for a barcode control, go here[^] and hope this can help you out.
|
|
|
|
|
not abl 2 understand ur question. anyway i assume that U have barcode scanner u want to read the barcode display it in some boxes. right?? for that there is no spl controls. place cursor in the textbox and scan the barcode using barcode scanner now the barcode will be displayed in textbox. if my assumption is correct the answer is correct.
|
|
|
|
|
first thanx for help
i had the bar code scaner and want to use what it read
(take what it read in any box (textbox))want to know which control to use
|
|
|
|
|
The simplest way to use a barcode scanner is as a keyboard replacement - that when a barcode is scanned, the scanner hardware or software simulate pressing the keys that correspond to the barcode data. Some just act as if they are a keyboard, some need some software (normally called a 'keyboard wedge' or 'scan wedge' or something like that) to do this. Consult the scanner's manual.
For advanced uses, there may be an API available to get input directly from the scanner, bypassing the keyboard. You might want to do this if you want to differentiate between keyed and scanned data.
To configure what sorts of barcodes the scanner will read, the scanner normally understands special programming barcodes. You can scan these to set the scanner up. You'll find these codes in the scanner's manual. Again, for advanced uses, there may well be an API for programming the scanner.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
I'm using a very fast loop and I'm using the Random object to get random numbers. The problem is that i'm suspecting that, as the loop is fast, numbers are not that random.
Is there a way to get to this? I've read something like locking the seed or something like that O_o
Thanx for any help.
|
|
|
|
|
|
It is outside.
Is there any way to randomize it more?
|
|
|
|
|
sergestusxx wrote: Is there any way to randomize it more?
What do you mean by randomizing it more? I've tested the random class and it seems to be quite random. You can specify a seed value in the class constructor.
Back in the old days with QuickBasic, one could use the statement RANDOMIZE TIMER and this would set the seed to whatever the PC's internal timer clock was at.
Try something like this:
Random randNum = new Random(DateTime.Now.Millisecond);
Everytime you have a new instance of randNum, it should generate a different set of random numbers (unless the code happens to be initiating at the same exact millisecond 1/1000 chance ).
Hope this helps some,
PJC
|
|
|
|
|
Problem is, it's not hard at all to have a loop hit that statement more than once per millisecond. And I've also seen some results that make me want a more random solution myself.
Try code model generation tools at BoneSoft.com.
|
|
|
|
|
BoneSoft wrote: it's not hard at all to have a loop hit that statement more than once per millisecond
It should be outside the loop. The original poster said outside the loop.
Another solution I thought of for the original poster was to create your own random number generator. The old Ada compiler that I have, the company had a sample random number generator program that was rather sophisticated.
|
|
|
|
|
|
The Random object produces a random number using the previous number as seed. It doesn't matter if you get the numbers an hour apart or a nanosecond apart, you will still get the same sequence of numbers.
Assuming of course that you use the same Random object, and doesn't create a new one for each random number.
---
b { font-weight: normal; }
|
|
|
|
|
If you doubt the "randomness" of System.Random (which is independent of the frequency you call Next() with), you should take a look at System.Security.Cryptography.RandomNumberGenerator and derived classes.
They tend to generate a better distribution of random numbers, from what I've read.
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|