It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I'm creating a MMO game. I will be using TCP client/server communication. At first my approach was to write both client and server in C++, but now I'm starting to think if it wouldn't be easier to write server in C#.
Client is going to be written in C++ because it needs to be cross-platform, but server will always be on Windows system. I consider choosing C# because it has an easier way of handling threads, built-in XML parser, etc.
My question is if it would be a good solution? Performance is still important to me, so if choosing C# over C++ would have a drastic influence on performance, I'd stick with C++.
Also if you think it's good idea, do you know if there are any tutorials that present communication between C# server and C++ client?
Thanks in advance for answers.
The performance difference between C++ and C# is not as large as you might think.
For the communications, if you're bothered about performance, use sockets and something like Google Protocol Buffers or Thrift. If you're less bothered about performance, use HTTP and JSON or XML.
Using different languages for client and server forces you to rewrite quite a bit of things in separate languages I would personally want to keep in sync:
Serialization and deserialization, although you could of course use some library for that. Google Protocol Buffers come to my mind, as they are explicitly designed to save bandwith and work "cross language".
Almost every entity of your game will have a more or less common set of properties. When going with different languages, you would have to keep these in sync manually and probably write them twice. This is especially annoying with more complex setters ;)
You will want to have some shared logic to "emulate" server answers on the client. Its important to predict on the client side what the server does to get a "snappy" behaviour. And what could emulate that behaviour better then using the same codebase for server and client?
I would't see a great problem with performance when using C# on the server though. That shouldn't be an aspect that strongly influences your decision.
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have made a game in C# with XNA. And I would like to make it playable online.
I want to be able to host a game on one machine and be able to connect to this game on other machines. Kinda like a listen server in Half Life.
This might seem like a pretty common problem that should have been solved a million times. But I have googled my ass off and i cant really seem to find any useful information.
I want to know exactly what I would need, concerning network-stuff, in order to create an online game with XNA, without using the microsoft-Live thingy.
A Library? the using-thing located in top of a class.
Code for initializing this stuff
How to look for another computer playing this game.
How to get/send data between the computers.
On which client are things calculated. If one guy would fire a bullet, should this bullet be created as an object on both clients? Or is one having the object,(checking for collisions etc.) and the other one just gets positions for draw?
I would like someone who has made a game like this to answer, what would be a standard approach.
The built-in XNA libraries are Live-focused, so you'll either have to live with that, or use a different network library.
The .NET UdpClient and Socket libraries are pretty straightforward.
Alternatively, have a look at the Lindgren open source network library. It includes some extension methods for sending XNA types like Matrix, Vector3, etc. which can be useful when you're getting started.
I wrote an answer for a question about making an MMO using lidgren, as mentioned above. It's got a few links to resources you can use to learn how to use it. I've used it personally to have a small test app with 5 users running around together, but I haven't taken it any further than that just yet.
Massive multiplayer in xna
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
So I'm thinking about making a GUI. My friend told me he knew how to do it in C#, so I went that method in setting the GUI up. Is there anyway to get a C# made GUI usable in java?
Yes you can. You absolutely should not.
I once wrote a perl application that used a VB GUI that i made, they communicated via OLE.
This is probably the worst construct you could ever do so don't :)
Not practically. You can't just give the C# compiler a Java file, or vice versa.
If you're really determined though, you can use IKVM to expose Windows Forms to Java.
There's also J# but it's not being actively developed anymore.
I think you should learn how to make a GUI in Java if you are coding in Java. However if you want both of C# and Java to interoperate, then you need a new layer which acts like a bridge between a C# program runs on CLR and Java program runs on JVM. The following link has a good explanation about how to call Java routines directly from a C# program over runtime bridges:
http://www.devx.com/interop/Article/19945/1954
You need to bind something on GUI with an appropriate logic. Such as File>New menu selection might exist for creating a new file. Therefore this menu command needs to be bound to a logic. You can not run away without writing these logic, the event handlers or without defining some other functionalities inside of GUI classes. Strictly speaking, you always need to write a lot of code on presentation layer which consists of GUI classes. So that, your friend does also need to build up the presentation layer itself. Because a useless user interface is called a prototype not a program. And also do not forget about that runtime bridges significantly decrease the performance. Eventually, I suggest you to go and learn how to make GUI in Java.
No! It would not work. Java's GUI classes are different, so even if you renamed your .cs files to .java files and made slight modifications, the code would not work.
No. It won't work. You can't compile Java and C# into a single executable package.
No. The way Java and .NET interact with the GUI is totally different.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
We have a lot of old legacy Perl scripts that connect to a MS SQL db process some records, and make files. Over time, the daily transaction size grew and these scripts are becoming more and more expensive.
Moreover, the Databases grew with more and more tables, and modifying the old Perl scripts is cumbersome. Was thinking about redoing some of the major scripts under .NET (in C#)
Is there a speed advantage under a machine running Windows Server of using one vs the other?
Again the idea is
Execute Query
Process Results through some basic formatting
Write results to a file
Depends on how stupid the respective programmers are. When initialized properly they both should be comfortable saturating whatever bandwidth you throw at them disc system wise - and THERE is your bottleneck. Make large cached writes (.NET BufferedStream) and make ure you have a SSD or something fast ready. The perforamcne bottleneck with proper programming is the disc subsystem for this type of work.
Both tasks can be done equally fast in either language. They can also both be done horribly wrong and horribly slowly in both languages, so there is that to consider.
From another one of your comments, you mention that you do the formatting on the SQL server side. These queries would potentially be a lot less expensive if you did that on the app side, and then moved this script to a faster machine so as to impact the db server the least.
I'd guess that harddrive speed is your biggest problem now. You should monitor the resources while running this script -- Is it maxing out your cpu? is it reading/writing a lot to memory?(it shouldnt). Is it just waiting on disk i/o most of the time? If it is, you should look into upgrading your storage to either faster disks, a raid, or an ssd depending on what makes the most sense for your situation.
Even just something like defragging the disk might help.
If you have good cpu/memory to spare but cant avoid the slow disk, you could even look into compressing all of the output in memory before writing it (again, assuming this is a good idea, it really depends on where these reports are going and what format is needed).
I don't expect great differences between those languages when it comes to write performance (generally bottleneck will be hard disk, not processing power of CPU) . You should rather take a look on "costs of maintaining code", in C# you can get much cleaner code, not to mention that integration with MS SQL probably will be more efficient, not to mention that you can use threading.
Better Code, more maintainable, maybe faster. Yeah C# is good idea
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I was just trying to post something to a website via my localhost to retrieve some data, and suddenly, this idea came to my mind: What happens if I create a post, put it into a for loop that runs over 1 million times, and send requests to a specific url for a million time? I just did not want to try to avoid any harm, but I wonder. And if this could cause some harm, how can I avoid such an attack?
this kind of things actually happen a lot. some are intentional and some are not. take for example: http://en.wikipedia.org/wiki/Slashdot_effect
other times, this is intentional, and its called a DoS (Denial Of Service). a lot of websites are taken down with these attacks, and not always involve an actual connection. it may suffice to saturate the listen backlog of the underlying os.
how to avoid it.. you cant, basically. you can make the best effort at it, but you will never be able to actually avoid it. after all, your website is there to be accessed, right?
You could add a rule in your firewall to block a specific IP address if that were to happen. If it is a sophisticated denial of service, I'm sure the IP address is spoofed and will be random. But for normal web sites, you won't need to worry about this.
Well, the server will get progressively bogged down until it figures out how to handle all 1,000,000 of those requests. Odds are, unless you have legendary hardware, it will become unresponsive and next to useless, creating a great disruption to everyone wanting to access it. This is called a Denial Of Service attack, or a DOS.
There's a few things you can do to prevent this:
Require users to verify that they are human before the server will process their request. This is usually done with Captchas.
Use an intelligent firewall to drop the packets or figure out how to have the server ignore requests from IP addresses that have been sending too many.
Make sure everybody loves your site so much that they wouldn't even think of doing anything to hurt it.
1 is probably most effective and simplest to do, and 3 is impossible. I can't offer a lot of advice about 2 due to lack of experience, and its probably fairly difficult and easy enough to exploit.
Short Story: Go with a Captcha. ;)
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I have always had an interest in coding, and a while back a started to learn C#. Since I only do this as a hobby, i have been learning it very slowly and don't know too much yet, but when I started to read about C++ and how it runs closer to the OS, I started to wonder if I should start learning C++ instead. I know html and JavaScript pretty well and to me C# seemed to be somewhat similar to js, so it wasn't to hard. I just downloaded C++ Express and noticed it is in a very different style than what I'm used to. I'm wondering if I should stick with c# or try c++ (especially if I want to start playing with Arduino sometime in the future). What are some advantages/ disadvantages to both?
As a person who has done all of these languages professionally, I would say that C# is probably the easiest to learn while still being very powerful. There is a lot of help for the .NET platform both from the libraries standpoint and from the community as well. Unless you really want to get down and dirty with a language, stick with C#.
The bigger answer, however, is "it depends". If you are looking to learn a language for the sake of learning one, C# is the way to go. However, if you are thinking about possibly using this new skill in a job setting, look for what type of job you want and decide from there. If you are looking to build applications for yourself and your friends, stick with C#. You can build a Winforms app in about five minutes and you can scale to larger and more professional apps easily from there. C++ will be much more difficult to do the same with.
Coming from Javascript, I would probably recommend staying with C# if you don't want to get down and dirty with details. It will take care of memory management and several other low-level concerns that C++ makes you deal with manually, so it's a little less of a shock to go from an interpreted scripting language like Javascript or Python or Ruby to C#. It's kinda half-way between them and C++.
That said, if you want to learn more of how programming languages and computers in general work, go for C++. It's more complicated than C#, but learning C++ very well makes any language you learn after that easy. Plus with C++, there's virtually no limit to what you can do (C# imposes a few limits), and you pretty much have the entire computer with all its speed and resources at your disposal.
That said, C++ usually takes longer to do the same thing in. For instance, creating a Windows application with a GUI and everything would take a considerable amount of time in C++, but in C# it's trivial. It's a tradeoff you have to deal with, but like I said, if you learn C++ first, C# is cake. The converse is not necessarily true though.
If you want to work with Arduino, go for C++ (never worked with Arduino but the code snippets looked like C so..). C++ is very similar to C, and most C will compile as C++ with very little modification.