Jump to content
Xtreme .Net Talk

XxBartmanxX

Members
  • Posts

    10
  • Joined

  • Last visited

About XxBartmanxX

  • Birthday 09/28/1986

Personal Information

  • Occupation
    Student
  • Visual Studio .NET Version
    Visual Studio .NET Enterprise Architect
  • .NET Preferred Language
    C#

XxBartmanxX's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Are you 100% sure that it is enabled?
  2. Hmm, it seems to be that way for a lot of people. You just have to think of keywords. In this case, looking up 'Socket' in the index will give you everything that you need. I think that it should be a similar process in VB .NET as in C#. Good luck
  3. Straight out of MSDN. I am assuming you are using C#, but regardless of that your answer is in MSDN.
  4. Hello and welcome to the Forums! I am not too familiar with VB .NET, but I do know C# and I am pretty sure it's similar across all .NET languages. So here it is: using System.Net; using System.Net.Sockets; using System.Collections; ... Bool bRunning = true; ArrayList socklist = new ArrayList(); ArrayList socklistcopy; Socket sockserv = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); sockserv.Bind(new IPEndPoint(IPAddress.Any, 4001)); sockserv.Listen(10); socklist.Add(sockserv); while(bRunning) { socklistcopy = new ArrayList(socklist); Socket.Select(socklistcopy, null, null, 1); foreach(Socket cursock in socklistcopy) { if(cursock == sockserv) { socklist.Add( sockserv.Accept() ); } else { byte [] buffer = new byte[1024]; int recvbytes = cursock.Recieve(buffer); if(recvbytes <= 0) { cursock.Close(); socklist.Remove(cursock); } else { //Do your stuff with the recieved data } } } } ... That should help you out, if not you can pm or email me. Bye, Mike
  5. Here is how I would do it, I am assuming you are using C# but regardless the same theories apply to any language. I adapted this from what I had been doing in C++ previously. You will need two ArrayList's, one for the master list of all connected sockets and another as a copy of the master for iterating through etc. First you will need to setup a socket to represent the server (create it, bind it, listen). Add it to the master socket ArrayList. Now, within the mainloop of your application you will need to do some looping. First, set the socket copy list equal to the master. Now, we will need a foreach() loop to iterate through every socket in the copy list. We need to check if there is data waiting on the socket, so we have a few options for this. We can use System.Net.Sockets.Socket.Select() or we can use System.Net.Sockets.Socket.Poll(). I am partial to Polling sockets so thats what I will use. At the begining of the loop, we have an if statement to see if poll() returns true or false. If it is true, then we can proceed with this socket. Otherwise, we ignore this socket and move on. The first thing we need to do, is see if the current socket is the server socket. If it is, then that means that we have a new connection attempt. Accept() the connection and add it to the master list. If it isn't the server socket, then it is another client that is already connected and we should recieve the data. If the recieve method returns a value less than or equal to 0, that means that the socket is disconnecting or the connection was interupted etc. I think that pretty much sums it up. I'm hoping I didn't leave anything out. Ah yes, if you need an example program let me know and I will put one together for you.
  6. Hey RonQ, Thank you for your reply. The @ character is for the string literal, which is exactly what you described. However, the problem is that \033 IS an escape code :confused: It represents pushing the Esc key on your keyboard, much like \b represent's pushing backspace. Putting the extra slash in has the same effect as the @ string literal :-\ Anyone else have any ideas how to make it evaluate '\033' has a whole and not as null followed by 33? Thanks
  7. I have a telnet server coded in C#, and I am trying to send text that is colorized to the client. This should be pretty trivial, but as it turns out it's not wanting to work. Here's how it works: For red foreground color you would send "\033[31m" to the telnet client. "\033" is the hex code for the Esc key I believe. Now, this worked fine and dandy back in my C++ days but for some reason C# is ignoring the entire escape code. It sees "\0" and interprets it as null, instead of looking at the whole "\033". Basically, I need to force it to look at the whole code and not just the \0. I am completely stumped at this point. To recap, I need it to interpret "\033" as a whole, and not as "\0 33". Thanks, Bartman
  8. Do you know what I just realized? You can override the WndProc of a form, and that was exactly what I was looking for lol
  9. I glanced at that briefly in my search through books and msdn, thanks for indicating that to be the right way to go.
  10. Hey, I don't know how many of you are familiar with C++ and Win32 programming, but here is what I would like to do in C#. I need to write my own event handler, much like you would write a message loop in C++. Bascially, I want to be able to handle every event fired off myself. For example, this is similar to what it would look like in C++. ... switch(msg) { case WM_RMCLICK: ... break; case WM_MINIMIZE: ... break; case WM_QUIT: ... break; default: ... break; } ... Take note that the ellipses are there as place holders for code :) Hopefully what I need to do is possible in C#, and hopefully you understand what I tried to explain. Thanks
×
×
  • Create New...