|
-
Aug 9th, 2012, 09:02 AM
#1
Thread Starter
Fanatic Member
Reusable socket server library or built into code ?
Hi all,
I've wanted to make a small IRC server for ages now, but each time I attempt to code it I get stuck on the networking part. I always want to build a massive socket server library that is multithreaded and can do connections on more than one port and handle all the sending and receiving, but now I am starting to doubt it's benefit vs cost. Is it wise to use a library for networking instead of building it directly into the application itself ?
-
Aug 9th, 2012, 09:20 AM
#2
Re: Reusable socket server library or built into code ?
Depends what you mean. For my money, I'd want to code the IRC server logic as handling a sequence of incoming messages, parsing them, responding to them and passing out messages. There would be no socket or networking code involved in this. I would have a separate piece of the server that dealt with socket connections and reading/writing data off those connections. I wouldn't consider this part as a 'library', it's simply supporting infrastructure to the code. It would use a library in the form of the .NET Sockets class and IO namespace generally. However, to be a library implies it can be packaged up and used by different applications - this code would simply do what the IRC server code needed support for, and not be generalised.
Does that give any perspective to you?
-
Aug 9th, 2012, 09:30 AM
#3
Thread Starter
Fanatic Member
Re: Reusable socket server library or built into code ?
Yes, I was wondering whether I should generalize my networking code into a dll so that all the applications I make can use it, but generalizing it will intern make the code of my applications more complicated and not all applications require a big networking library. I'm thinking of doing what you said I was just wondering what the other people do with their projects that have to act as a server.
I will leave this open if anyone else has some input. For the time being i'm going to scratch the idea of a networking dll.
-
Aug 10th, 2012, 12:44 PM
#4
Re: Reusable socket server library or built into code ?
What is a 'big network library'? A 'server' and a 'client' is all any network library fundamentally needs. You just build on those blocks. Once you build a library (e.g. a TCP server and client) you can reuse it over and over for all your TCP needs. I have my own which I use for communication with: PLCs, Computer to computer, inter-process, intra-process, internet, intranet; anywhere a TCP client or server is needed. The protocol over TCP is built in another library, and the application references that library.
While building a reliable TCP server is not trivial, it is not a huge undertaking. I believe JMC has a link in the code bank, as a baseline or as-is. Having a reusable library is very useful. As far as the protocols (e.g. IRC) go, I personally like it separate from the underlying 'transport' mechanism.
"Ok, my response to that is pending a Google search" - Bucky Katt.
"There are two types of people in the world: Those who can extrapolate from incomplete data sets." - Unk.
"Before you can 'think outside the box' you need to understand where the box is."
-
Aug 10th, 2012, 05:31 PM
#5
Thread Starter
Fanatic Member
Re: Reusable socket server library or built into code ?
What I mean with a big network library is a dll that I can reference in any project that is a tcp server. What I mean by that is it can listen on multiple ports and can have many connections to it. It will handle sending and recieveing and communicate the data back via events or another method. This library will also need to be multithreaded quite a bit. My original question was whether to build this functionality into my application itself, or turn it into a library so that my other applications can use it as well. I decided to build it into my application because It makes things too complicated to generalize it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|