|
Hello,
I currently have C++ server and C# client which communicate well using sockets.
But I may need to add some functionality on server side, and I prefer to do that using C# - so can I write a proxy c# application which will receive requests from client, do some processing and forward that to C++ server? and then back to client? is it possible?
|
|
|
|
|
Well...yes...but why?
That's a rather convoluted solution to a problem.
Why not call the C# code on the server? If the C++ code is managed, then it will call it without any problems. If it isn't, then it's not complicated to do: Google "call c# code from unmanaged c++"[^]
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
It's entirely possible provided that security allows it. What you're trying to do could be viewed as a 'man-in-the-middle' attack though so if you've got transport level security on you're going to run into trouble.
I wrote some code a while back to do just this, create a proxy for WCF net.tcp services on other boxes. Where you have multiple services talking to each other on the same box, you can debug one locally and create proxies to real services elsewhere.
Drop me a line if you want some code, but it doesn't inspect the message at all, just intercept and relay.
Regards,
Rob Philpott.
|
|
|
|
|
Thanks but would not writing it be exactly same as writing ordinary
C# client and server using sockets? Just server would get message from other C# client, then forward it to C++ server?
|
|
|
|
|
Yep.
TcpListener/TcpClient on way in, TcpClient on way through.
Regards,
Rob Philpott.
|
|
|
|
|
Would this be efficient?
Or make my program much slower in general?
|
|
|
|
|
i need to prepare for C# interview so any one can suggest a best books for links to crack the interview
|
|
|
|
|
If only there were a book called, oh I don't know, having experience in the language. That's your best book there. Sure, you can review the fundamentals in something like Jon Skeet's C# In Depth, but it's experience that cracks interviews, not cramming on a book beforehand.
This space for rent
|
|
|
|
|
Books, tutorials, and "interview question" sheets won't help you: the only way to "crack the interview" is actually to know your subject, and apply for jobs that use stuff you know well.
Ignoring that a technical book on C# is likely to be 1000+ pages and take a good long time to read properly, especially if you do the exercises - without which there isn't a lot of point in reading it at all - anything you can pick up and read in a couple of days before an interview will be useless as soon as the interviewers ask for a deeper explanation, or a follow up question.
Get experience, know your subject well, and apply for suitable jobs. That is the only way to get a job instead of other applicants who do exactly that...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
An interview is to see if your levels of knowledge match what the company is looking for. If you try and cheat the process and make it look like you know more than you do then that is unethical and doesn't help the company or you. How would you like it if you paid someone to work on your car, and when they started you find out they don't know much about cars and had misrepresented themselves in order to convince you to hire them?
The reason so many questions are posted here that are simply people trying to get others to do their work for them is because they are in jobs they are not suitable for, probably because they cheated their interview too.
|
|
|
|
|
Having just done 12 interviews to hire 2 contractors my advice is forget it! If you can tell me why you did something, in detail with the supporting arguments your toast. Longest interview was 1 hour 20 minutes, shortest 12 minutes.
Also make sure you can speak the language, well, if I struggle to understand your accent you are not going to get the gig!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Rather than a C# handbook, the more important things to know are:
- Your recent projects, technical details about them, in addition to where they fit into the big picture,
- Were you just listening to instructions in this project, or did you propose suggestions, design changes, and why. What difference did you make?
- What aspects of these projects could you have done better, in hindsight,
- What did you learn during the last six months; do you have any evidence of this, in terms of producing artifacts.
|
|
|
|
|
|
|
Rob Philpott wrote: Well, since all the replies have been anything but helpful
I'd disagree: If he thinks that quickly reading a book on a subject as huge as this (and both your your recommendations are excellent, but will take weeks to read properly) then he is just wasting his time going to the interview, the employers time interviewing him, and if he gets the job (hah!) then everybody who could do the job's time until they realise and throw him back out, so they can start interviewing all over again!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I don't think reading a book prior to an interview necessarily dictates that he has no knowledge of what he's doing - he didn't say that, it's a fair question. I've yet to have an interview I can't handle technically, but I still read stuff prior to going.
And even if the question is misguided, a whole group of people saying give up, get a career change etc. IMO is unhelpful as well as condescending.
Also, the book recommendation is valid to anyone reading the thread who might not be trying to wing an interview. These are excellent books.
Regards,
Rob Philpott.
|
|
|
|
|
Only one person suggested giving up and getting a career change. Everyone else suggested that experience would be a better choice.
This space for rent
|
|
|
|
|
You're doomed ... if you need to ask others for "book recommendations" at this stage of the game.
You should have created your own list of reference materials by now.
The fact you don't indicates a lack of initiative and commitment (IMO). Find another career.
|
|
|
|
|
I have already checked other questions here but the answers are not related to my issue. the following code allows textbox1 to only accept numbers if the physical keyboard (laptop) is pressed:
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
char ch = e.KeyChar;
if ( !char.IsDigit(ch))
{
e.Handled = true;
}
}
but this is not what I wanted (I dont use physical laptop keyboard).
I have windows form with buttons and a textbox1. I designed keyboard and it works well but I want textbox1 to only accept numbers and the ".".
There are only two lines of code inside each button (and only code in the project) which is:
private void buttonName_Click(object sender, EventArgs e)
{
// each button only has this code.
textBox1.Focus();
SendKeys.Send(buttonName.Text);
}
I know how to set textbox to accept numbers if the physical (laptop ) keys are pressed but here in this case I have windows form with control buttons ( each button to print its text into textbox1) and I want to set textBox1 to only accept numbers and the ".". Please help in how to achieve this. Thank you
|
|
|
|
|
Use the .TextChanged event as another avenue for filtering / altering text box input.
|
|
|
|
|
You can use TextChanged event as Gerry said.
Then you can verify the text using this method.
public static bool IsNumber(string s)
{
var r = new Regex(@"^-?[0-9]\d*(\.\d+)?$");
return r.Match(s).Success;
}
BTW it also accept negative numbers
|
|
|
|
|
Assuming this is Windows Forms, and there's no physical keyboard:
private void NumberButtons_Click(object sender, EventArgs e)
{
textBox1.AppendText((sender as Button).Text);
} The assumption here is that you have a set of Buttons whose Text values are from #1~9 and #0, and they all use the same Click EventHandler.
Of course, we don't know here exactly what you mean by "numbers:" are you allowing decimal-point, commas, negative numbers, culture-specific numeric encoding, etc. ?
Will also have a back-space button ? If you wish the user to have some way to move the insertion point around in the TextBox, that'll take a bit more work (using virtual arrow-key buttons ?).
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.
modified 22-Nov-15 1:58am.
|
|
|
|
|
Using the code below, I am trying to find the text
<add key="GetListDefaultResultSize" value="6500" />
but when I view what my program is seeing, it is actually seeing
<add key=\"GetListDefaultResultSize\" value=\"6500\" />
How do I adjust for the escape characters that are added before the quotes when my code does a File.ReadAllText?
string allFileText = File.ReadAllText(networkFilePath);
if (allFileText.Contains(replacementLine))
{
lvwAppendFiles.Items.Add(networkFilePath + " contains " + replacementLine);
}
else
{
lvwAppendFiles.Items.Add(networkFilePath + " does NOT contain " + replacementLine);
}
|
|
|
|
|
Since it looks like XML, I would consider using the
System.Xml and System.Xml.Linq classes instead of trying to interpret the input myself.
|
|
|
|
|
If you are looking at the string in the debugger, it is the debugger that is adding the escape characters to what it is displaying, they aren't actually in the string.
The easy way to verify this is to check the Length of the string. It should not include the escape characters in the count.
"Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed."
- G.K. Chesterton
|
|
|
|