|
File.ReadAllBytes will read your file. Synching to what part of the data is being viewed right now, is probably the main challenge.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I recently made a server and client in separate EXEs and I would like to run both on one PC. The server is listening on port 19357 and of course the client will connect via the same port. Of course this causes a conflict and an exception is thrown. I know it is possible to do this, I just don't know what I'm missing. For now I have a 'bandaid' on the problem by changing the port that the client connects through and forwarding the port through my router to the correct port. However I do not wish to use this as a permanent solution.
My server uses the following code to listen:
tlsClient = new TcpListener(19357);
tlsClient.Start();
My client uses the following code to connect:
tcpServer.Connect(strHost, 19357);
And of course my threaded to keep listening for incoming connections.
I can change the address in my client to 127.0.0.1 without any problems, but if I try to use my domain as the address on the PC that is running the host, I get an error about the port being in use. I know it is possible to connect in the method that I'm talking about because I am running Apache web server on this PC and I am able to connect to the server with a web browser using my domain as the address. But of course when I go check to see what ports are in use, i get some random number as the local port and 80 as the remote port. The web browser just cycles through ports on the local side until it finds one not in use while still connecting to the proper port on the remote end. How can I do this with my program?
Thanks,
Thomas
|
|
|
|
|
sirEgGhEaD wrote: Of course this causes a conflict and an exception is thrown. I know it is possible to do this, I just don't know what I'm missing.
Please entertain my ignorance, but, exactly what conflict are you referring to? If a server listens on port X, and a client connects to port X, what is the conflict?
|
|
|
|
|
After my server is running and I attempt to use my client to connect, I get an exception because the port is already in use.
|
|
|
|
|
Show the code where you create the TcpClient instance.
|
|
|
|
|
|
You did not show the code that instantiates the client. You only showed the call to the connect method.
Show the code that creates the client.
|
|
|
|
|
My server uses the following code to listen:
tlsClient = new TcpListener(19357);
tlsClient.Start()
My client uses the following code to connect:
tcpServer = new TcpClient();
tcpServer.Connect(strHost, 19357);
|
|
|
|
|
I thought you might have been mistakenly attempting to bind the client to the same port as the server was listening on.
Do you get the exception when the server is created or when you call the connect method of the client?
|
|
|
|
|
Well that is my thought as well. I run the server, and start listening with no problems, no exceptions. I run the client and attempt to connect and the exception is thrown. I haven't had this problem when writing TCPIP programs in the past. This is my first attempt at one with the .net framework. But it does seem to be attempting to bind the client on the same port that the server is listening on. I wish I knew how to change this and have the client connect to the server on the proper port, but bind a different port on the local end.
|
|
|
|
|
You're right. Winsock is supposed to automatically bind the socket to whatever port is available when you call "connect."
Have you investigated the other TcpClient constructors? I see there are others that allow you to specify what endpoint to bind the client socket to.
|
|
|
|
|
Nah, I haven't worked with TCPIP stuff enough to know. I'm not very advanced in C#, or any language for Windows for that matter. That's why I'm here. Hoping that someone does know and can point me in the right direction.
|
|
|
|
|
Well, here are the only other things I didn't ask:
What are you putting as the host name in the "connect" call?
And what exactly is the exception?
|
|
|
|
|
The address is a string containing my domain name, but since I am getting an error I have been using:
tcpServer.Connect(IPAddress.Parse("127.0.0.1"), 19357);
And I've been redesigning my software so I couldn't tell you EXACTLY what the error is but I do know it was of type System.Net.Sockets.SocketException. I remember it saying it could not bind the port or making a suggestion that it was already in use. I wish I had my software back in working condition now to test it. It will be a day or two before I can though. Perhaps what I have provided will be enough though.
|
|
|
|
|
Well...I got my software back to a point to where the server and client could connect to each other but not really communicate as the new protocol isn't in place. But anyway, I tried connecting using my domain as before and I got no error at all. I checked and the client connected via port 1668 on the local end. So I have no idea why I would have gotten the error before and not now. Obviously I was doing something different though. Thanks for all your time and help. If I ever figure out what was going on I will let you know.
Thanks again,
Thomas
|
|
|
|
|
how can I validate if the email address provided by the user does exists or not before proceeding to send an email using SmtpClient?
|
|
|
|
|
jrahma wrote: before proceeding to send an email using SmtpClient
You can not!!!
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
so you mean there is not way to send whatever call or (ping!) to the email to verify if the email was correct or it's just a fake email?
|
|
|
|
|
Untill and unless you do not send the email, you can not.
But, why would you do this? This is usually done by spammers to get hold of actual email addresses
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
because I have a feedback form and I want to make sure the email was correct in order to reply yo the user and to avoid people sending me junk emails using fake addresses..
so what's the solution?
|
|
|
|
|
jrahma wrote: so what's the solution?
If you can come up with a reliable method to do this, you'll become very, very rich. There's currently no foolproof way to do this.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
As he has been saying there is no way to verify an email address is valid unless you send a message. Most applications rely on the user to provide a correct email and warn them if the email is not correct they will not get any messages.
Other ways to eliminate potential fake emails is to send a confirmation and only active the email if the user responds. You can remove any email addresses that have not been responded to in a certain time period.
only two letters away from being an asset
|
|
|
|
|
IIRC (it was a long time ago) the best I was ever able to come up with was to validate the email address with regex and do a look up for the MX records of the domain of the email address.
This won't ensure the email address exists - daveym69[at]microsoft.com would pass (don't want spam bots hitting MS mail servers hence the [at]!), but at least you know it's properly formed and the domain actually has a mail server.
|
|
|
|
|
Hi there,
Have a look into CAPTCHA's.
If you don't like this, another option to add a hidden textbox. Spam bots will generally fill in every box on the page (hidden or not) and then submit the form.
All you have to do is check that the hidden box is empty - if not, it is a non-human user.
Cheers,
Mark Brock
"We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen
|
|
|
|
|
I might be mistaken, but I think there's something in the SMTP protocol which allows this. If you're feeling particularly masochistic you could implement this. I think it works in a similar way to POP - that is, text based requests and responses.
|
|
|
|