Quantcast
Viewing all articles
Browse latest Browse all 3

Answer by palacsint for Implementation of an asynchronous TCP/UDP server

1, Create (at least) two classes. One for UDP and one for TCP. It would omit lots of code like this:

if (this.Type == ServerType.TCP) {    ...} else if (this.Type == ServerType.UDP) {    ...}

Maybe a common abstract parent class and a factory are also required.

2, Anyway, in the following snippet the last else branch should throw an exception:

if (this.Type == ServerType.TCP) {    ...} else if (this.Type == ServerType.UDP) {    ...} else {    return null;}

I don't think that there is any state when Type != TCP and Type != UDP too.


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>