Jump to content
  • Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About invictus

  • Rank
  1. Hi I am trying to convert my networked application (C on linux, using a custom text based protocol) to support UTF-8. I have search the Internet for a while now in order to find the best way to read UTF-8 from the socket, however, I have not been successful. Can anyone point me in the right direction to get started? I have little experience with unicode programming in C, but know there exists a wchar_t type somewhere.
  2. invictus

    Non-blocking sockets limitations?

    Quote:Original post by SteveTaylor I would recommend always using a separate input thread, but only one for the lifetime of the program, not one per connection. So lets assume I have a UDP application I process data and send udp-packets during processing. Instead of also receiving data in between processing its recommended to have a separate thread reading (maybe even blocking) on the thread and dumping it in an application level buffer until the main(processing) thread have time to pick it up? In that case it will always read the data as it arrives, and nothing needs to be dropped although I utilize the main thread for processing? Is this a better idea?
  3. Hi There is a question I have been wondering about non-blocking sockets. With blocking sockets I can just ask the program to wait for input data, but with non-blocking sockets I obviously need to ask for data at the correct times...what happens if I dont? Lets assume some data arrives on the socket, but due to some other heavy processing on the thread, it takes a few seconds before the app checks for incoming data...is the data lost/dropped in the meantime? How much time/data do I have between the data actually arrives until I have to be read in order for me to actually being able to read it? I really appreciate any feedback you might have!
  4. Quote:Original post by hplus0603 The whole point of signal() is that it will interrupt system calls -- including accept(). It is the lightest-weight option among those suggested. Note that system calls are, generally, defined as atomic, so if you have a pending write() call for 500,000,000 bytes, going to a slow disk, then it's likely that the call won't be interrupted until after all the bytes have been transferred, unless the OS implements rollback on the file system (unlikely). Also note that, if you start using signal(), you can't assume that you will get signals only when you're blocking, or only when blocking in accept(), so your code suddenly has to be aware of pre-emptive interrupts. A quick and dirty way around that problem is to block the signal in question with sigblock() or similar, and unblock only when calling accept() (and re-blocking after it returns). Interesting...but how can I control which thread gets signaled? If I have 10 threads going in addition to the mainthread, and all these threads are blocking on recv(), what stops signal() from interrupting all of them or any random one of them?
  5. Quote:Original post by Bregma Quote:Original post by invictus Using C as language and UNIX sockets. Put your listen socket in non-blocking mode. Create a local pipe, set it to nonblocking mode. Use select() to do blocking wait on both descriptors. Have your working threads write to the local pipe. On return from select(), the accepting thread either does an accept() on the listen socket or cleans up, or both, depending on which descritors have available reads. That's the traditional way. Just 'cos it's a thread doesn't mean you can't use traditional techniques. --smw This is really interesting. What is the downside of this approach? Large overhead?
  6. Quote:Original post by SnotBob You could signal() the main thread. Of course that doesn't really break out of the accept(), but should be good for cleanup. How can that help me then?
  7. Quote:Original post by Evil Steve You could set a flag somewhere and then set up a socket from your other thread and connect() to yourself. That'll break out from accept(), and you can check the flag to see if it was yourself connecting and if so do whatever you like. This is an interesting idea, but it seems a bit costly for doing what I want to do...
  8. Hi When I use a threaded socket model where the main-thread of my application are blocking on accept() and all the client connections are handled my different threads, is there any way I can cancel this accept() from another thread? The reason why I am asking is that I want the mainthread to do some cleaning up after a thread completes its work (e.g. the client occupying the thread disconnects). As a result I would like the mainthread to know when a thread completes. Since the mainthread are mostly blocking I was thinking it should in some way be able to get a notification that a thread has finished and then cancel the accept() to do the cleanup before re-accept()'ing. Any suggestions? Using C as language and UNIX sockets.
  9. invictus

    game overlay

    Hi Anyone have any idea how I can draw to the screen of another game like Fraps does with its FPS counter?
  10. invictus

    plotting crossing lines

    Hi I have a small problem. I have 2 coordinates (x1,y1 and x2,y2). From these I was going to calculate the length between the points. This by itself is not problem. The problem is this: The distance between the points form a line of a given length. Along this line I want to calculate 10 (equally aligned) crossing lines that are 10 units long in each direction from the base line with a 90 degree angle. The lines are of no importance by themselves, but the x,y coordinates at both ends are. Can anyone help me out in the right direction here? Take a look in the following drawing: http://home.online.no/~bj-bakke/lines.png I am using this information in order to create a small utility to help he analyze images for use in biometric authentication (non-profit research project).
  11. invictus

    simple math question

    Given the following situation: http://home.online.no/~bj-bakke/angle.png lets say I have a x,y cordinate system and only have an angle ("a"). Is there any way I can get the x/y ratio from this? That is; on a given x with angle a, what is y? on a given y with angle a, what is x? The corner/angle is always at x=0, y=0
  12. Thanks. It was overlay I was wondering about. Its a good start, but any more suggestions would also be accepted with a smile :)
  13. Hi Do anyone know how I can draw to an external games display/rendering context? I dont really care if the method uses directx/opengl/gdi spesific api, but what I am after is something like fraps's FPS overlay in games. Any ideas where to start? Would be an advantage if the method managed to do so without flickering. [Edited by - invictus on November 20, 2006 10:19:14 AM]
  14. invictus

    OpenGL for 2D-games. Worth it?

    Ok thanks guys. Actually I didnt explain myself good enough. The reason for me wanting to being able to write pixels into the framebuffer is because I am testing some graphics algoritms on image files. the 2D games I could write using the quad+texture method you mentioned. I was just hoping I could use same graphics library for both so I dont have to learn two different ones. So the real question is: - Can I use OpenGL for putting pixels directly in the framebuffer for testing purposes? Performance doesnt matter. (how DO I put pixels directly into the framebuffer with opengl anyway?). - Is OpenGL the best Linux library for making 2D-games without using models but only images for representing objects? Performance matter. I think you guys answered both :) I am sorry for the bad explanation at first. [Edited by - invictus on April 25, 2006 2:09:21 PM]
  15. invictus

    OpenGL for 2D-games. Worth it?

    Quote:Original post by OrangyTang OpenGL works great for 2d games. You can get much higher performance, greater flexibility and much higher quality rendering than old-style bliting. Does that include games with no models at all, just regular images drawn to the screen?
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!