|
If you are running a transparent proxy, you dont need to change anything on the clients. The proxy get automatically used for outgoing requests to port 80 as directed by iptables in linux. You can verify this by inspecting the http repsonse headers. Squid should add 1 or 2 headers to the response. If your are using this for webservices you mite wanna disable caching on the webservice else your requests will be cached by squid.
xacc-ide 0.0.99-preview
|
|
|
|
|
No, I want to run a transparent proxy that redirect all http packets to caqche server.
How can I do it?
|
|
|
|
|
Hi
I want to redirect all my network traffic especially UDP through proxy server. I want to change contents of some of my packets and then send that packet to the destination. Any idea how I can do this. I am not good in C, any solutions in C# will be a plus as I have to complete it early.
|
|
|
|
|
Hi,
I'm having some trouble with random numbers.
I'm building a BTree structure but wether the node I'm inserting goes left or right needs to be random.
The problem is that:
Random rand = new Random();
int num = rand.Next(1,3);
always produces the same number everytime time the function is called.
I tried generating 2000 numbers in a list and found that about 1/3 were 2, the next 1/3 were 1 and the next 1/3 were 2.
Basically the default seed is the current time's Millisecond property.
I tried setting my own seed and had the same results.
If I do System.Threading.Thread.Sleep(1000) I get what looks like a valid set of random numbers.
The problems is I can't wait for 1 second per Random number as I need to make thousands of these decisions in a short space of time.
Is there a seed I can provide, mayve a smaller number than Millisecond?
I was thinking of having an array of seeds, and everytime I need a random numbr, then choose the next seed in the list, and add it to the current time.
This way, even when the same element of the array is selected when it loops around the seed will be different.
The problem is I really couldn't be bothered coming up with thousands of numbers for this.
Is there an easier way?
Thanks,
Stephen York
|
|
|
|
|
How silly can I be?
I was creating a new Random object every time I needed a new number.
I took the declaration out and declared it globally and assigned it in my class's constructor.
Please ignore my silliness.
|
|
|
|
|
|
I have loaded and image into an imagelist. Now how can I convert this into a System.Drawing.Icon so that I can use it as an icon.
|
|
|
|
|
Do you actually want it output as a .ico file or just for use in your application ?
|
|
|
|
|
Here is a function which could run for a while.
So I put it into a thread.
Now I want get the result as soon as it returns.
How to do it?
Thanks!
|
|
|
|
|
The thread function can't return a value, because you don't know when it will complete. The only way is to share a variable and make the thread signal to the original thread when it has completed updating the variable.
class Test
{
int val = 0;
AutoResetEvent evt = new AutoResetEvent(false);
void MainThread()
{
new Thread(new ThreadStart(ThreadFunc)).Start();
evt.WaitOne();
Console.WriteLine(val);
}
void ThreadFunc()
{
Thread.Sleep(2000);
val = 1000;
evt.Set();
}
}
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Every time I new a TcpClient , it takes me almost 30 seconds.
Is it too slowly?
Is there any way to increase the speed?
Thanks a lot!
|
|
|
|
|
Hi,
do you know if there is an exam available for windows c# 2.0 ?
Thanks
|
|
|
|
|
|
Hi
I have created a utility class which contains static methods to do some utility functions. I believe that only one instance of this method is created for this class and all objects use the same instance.
My concern is this: If multiple threads access the method simultaneously, are the variables in the static method used thread safe? is it possible that they mgith be corrupt?
Please advise. I am wondering whether to make these methods instance methods.
Thanks
TSR
|
|
|
|
|
Local variables inside methods are always stored on the stack, and each thread has its own stack, so this is absolutely thread-safe.
Static fields inside the class are something different...
|
|
|
|
|
|
tsramkumar wrote:
y one instance of this method is created for this class
Not really. There are no instances for methods, static or otherwise. When your application loads up, these methods (the compiled code, actually) are loaded into memory (a special section called .text) and that's it.
That memory is totally different from memory used by local variables. Local variables are created on the stack and each invocation of the function creates them, so yeah, you are safe as long as the variables you refer to are local variables.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thanks. I have only local variables in my static method (it does call another static method in a utility class, but that too uses local variables only). So as long as I use only local variables in static methods, the code should be thread safe right.
Thanks once again for clarifying this.
Ram.
|
|
|
|
|
Anything static must be treated with care in a MT system. As you have guessed any thread could access it at any time causing wackiness to ensue. In general I would avoid any static members in objects that are going to be in an MT system. static methods aren't as toxic because any locals are stored on the stack of the thread but can be problematic if it access other things that have static members or worse members.
|
|
|
|
|
Hello,
Does anyone know any sources where I can find the function, or any info that would be able to calculate IRR for a range of values, with the given initial rate?
I am thinking of using recursion, any ideas?
Thank you
|
|
|
|
|
There are well known staticstical formulas for this. We did them all in 1st year in University. I doubt any one of them included recursion, as we used calculators. Maybe a loop or 2
xacc-ide 0.0.99-preview
|
|
|
|
|
I know the formula, and indeed it's pretty simple. However, how can you use a loop or two, if you don't know how many times you will be calculating the IRR. Meaning, the first value of IRR is just a guess, and then the function will go through an array of values, to calculate the specific sum, and if the sum is not equal zero, then it picks another IRR rate value (based on a certain rule), and does the same sum operation. Therefore, it's not a loop or 2.
|
|
|
|
|
Hi there!
I hope you guys can help me, here's my problem:
I have a form (Form1) with a button (Button1) which open another form (Form2) as such:
<br />
Form2 frm2 = new Form2()<br />
<br />
frm2.Show();<br />
On the second form (Form2) I have a DataGridView with this code:
<br />
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)<br />
{<br />
this.Close();<br />
}<br />
My goal is to close the second form when the user double-clicks (makes a selection) in the DataGridView. I've tried more than 20 events and I always have the same problem:
Object reference not set to an instance of an object.
at System.Windows.Forms.DataGridView.HitTest(Int32 x, Int32 y)
Can you guys help me? Thanks!
|
|
|
|
|
I tried this with a DataGrid control and had no problems... where are you getting this DataGridView control?
|
|
|
|
|
Ahhhh, of course, sorry!
I'm using Visual Studio 2005 Beta 2... It's a grid that comes with .NET 2.0. It's VERY useful, much better than the old DataGrid IMHO.
|
|
|
|