Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

200 Neutral

About peter_b

  • Rank
  1. Yeah but the point is automatic generation of indexes. Lets say we have a class: template<int IDX> class IndexedMember { enum {m_index = IDX}; }; Then it should be possible to use it like this: class Whatever { IndexedMember<__COUNTER_EQUALENT__> m1; IndexedMember<__COUNTER_EQUALENT__> m2; IndexedMember<__COUNTER_EQUALENT__> m3; } I dont want to do: class Whatever { IndexedMember<yellow> m1; IndexedMember<red> m2; IndexedMember<blue> m3; } because then i might aswell do: class Whatever { IndexedMember<0> m1; IndexedMember<1> m2; IndexedMember<2> m3; } Which is the way it works right now, which is really bad since the project is huge and it causes many problems when new members are added and the updating of indices are overlooked.
  2. no fred, it has to automatically increase an assignable value, otherwise i might as well type the index numbers manually, and that's what i don't want to do.
  3. In using GCC 4.1 im afraid, so it's not supported. Changing compiler is not an option either. Is there any other way to simulate this behaviour with some macro tricks or something?
  4. Is there any nifty preprocessor trick to generate an increasing index at compiletime? For instance, i want to do something like this: int one = AUTO_MAGIC_INDEX; int two = AUTO_MAGIC_INDEX; int three = AUTO_MAGIC_INDEX; int four = AUTO_MAGIC_INDEX; which would generate: one == 1; two == 2; three == 3; four == 4; What i want to use this for is to be able to have a class-member index.
  5. If i have a string, lets say the string is "System.Float". Is there anyway i can get the type from that string? (ie a float). And do something like this: Float f = new StringToType("System.Float")();
  6. hplus: Do you know if its possible to bind a tcp socket using SO_REUSEADDR to a port that is already in use, but is bound by another application(on win32)? For instance if you are running a server of some application you have not written yourself behind a NAT, and you would like to be able to connect to it. Then you could write an application that at some fixed time would try to punch a hole to the computer you would connect from(static address). Could this work?
  7. peter_b

    Limiting upstream troughput

    Quote:Original post by Antheus What kind of sockets are you using? Blocking or non-blocking? With blocking, send will block if you exceed the buffer size until more room is available. With non-blocking, you get a WSAEWOULDBLOCK error. But buffer sizes do not affect packet loss. Since apparently you need all packets to arrive, you'll need some acknowledgment scheme. When peer receives a packet, it sends a response indicating which packet it received. With multi-client servers the above problems tend not to be an issue, since server will be serving many peers, and will not run the risk of overflowing client's buffer. If however you want to take control over traffic, then simply keep a track of how many packets are in transit to a given peer. Once you receive an acknowledgment, send either more data, or re-send lost packets. The problem you're dealing with is more likely to occur on LAN. Since packets are delivered almost instantly, it's easy to flood client's buffer so that application doesn't have time to clear it fast enough. Over WAN, varying latency makes such particular situation somewhat less likely. But in general, if you want to ensure things arrive, you'll need to implement either acknowledgment scheme, or simply use TCP. Thanks for your awnser! I am using non-blocking sockets, and i have a protocol for numbering packets so that they arrive in sequence, and sending ACK's so that they are resent within a certin time if they dont get an ACK. So it dosn't matter that i am flooding the send and receive buffers before i can empty them, because the ack-resend-logic will resends any packets that was lost due to flooding. But it seems like an awful waste to rely on packets beeing resent instead of just limiting the rate at which im sending packets. Im thinking there should be some way to calculate about how much data you can send per second if you have the roundtrip time etc. Ofcourse this is also limited by bandwidth, which there is no way to know i think, unless you try to calculate it.
  8. When sending large files using udp, there will be alot of packets dropped if one does not somehow limit the rate at which the data is sent. But what values should one use for this limitation? For instance, if i call send() and pushes like 30x1500byte packets trough my socket at the same time. Only 5-6 of those will reach its destionation. Setting SO_RCVBUF to a large value on the remote host will make this work better. But that aint a good solution since the protocol should not have any restriction to how large files it can send. What values should i use to calculate how fast i should send the data? 8096bytes which is the standard value for RCV and SNDBUF on winsock seems like a nice value. But 8096 bytes over what timeframe? ^.- Thanks
  9. Hello, i have some questions about NAT punchtrough & p2p. 1. (this is really about p2p) Does it work like this? Two peer's connect to a central server, which tell's both peer's about the other one's address. They both start sending "punchtrough" packets to the other one until one of the has been reached by the other one, hoping that the NAT machine will start remembering to forward the packets to the correct lan address. 2. What if the p2p server is hosted on a computer that has both a private lan behind it, and is also connected to the internet. Is it possible that its socket listens on two nic's at once? (is this possible?). In that case, what if one client is from the private lan, and one is from the internet, then the one on the internet would be sent a private lan address to it from the server (the address the server see's), it wont be able to connect to it. 3. Is NAT-punchtrough guaranteed to work if done properly? I have a hard time thinking it is with all the firewall rules and private lans that exist on the internet. Is a p2p solution even viable? I mean would you often find yourself in a seat where a client can connect to the server, but the punchtrough fails between some of the clients, so they will have to be disconnected. 4. (edit) On a sidenote! =] TCP-punchtrough.. is it possible? =] does NAT-gateways analyze the internal content of tcp-packets and make their forwarding decision based upon if the handshake is done properly, or would it be enough to have booth peer's call connect() in intervals to make the punch-trough, instead of like with udp, sending dummy packets? =] Thanks for any input. =] [Edited by - peter_b on February 7, 2008 1:21:07 AM]
  10. Hello. Im new to the idea of peer to peer networking when it comes to implementations for games, only designed client-server in the past. I have a few questions about some of the problems i can foresee when im going to start coding this. Questions: Question 1: How does it work? =P Will one "peer" initiate a listen(), and then the other peer's may connect to that peer, and it distributes all the peer's addresses so that they also can connect to each other? So that in fact it is one peer that is a kind of "server"? Or am i getting this wrong? Question 2: What if there are 4 peers, connecting to each other, But the connection between 2 of them are prevented by internet routing/firewalls/whatever.. What is a common solution? Fallback on a server topology to enable communication anyway? But it goes trough a peer that acts as a server instead? Question 3: Assuming im right in "Question 1". Imagine the following scenario. Peer1 starts to listen for connections. Peer2 and Peer3 connects to Peer1. Peer1 transmits the ip's of Peer2 and Peer3 to them both. Both they are both behind a firewall that does not forward the gameport im using to their machines on their LAN. So all packets they try to send to each other will be dropped. What to do? :O Those are the questions i can think of on top of my head. I have not yet begun to implement a p2p protocol for my game, are there any other pitfalls i should be aware of? Client-server games i have done many times before and they work well, so even if that may be a better solution, i am going to try this approach because i want learn it. Thanks in advance. =]
  11. Hello, i have a problem. I am currently developing software for several platforms in msvc 7.1. It seems its not possible to add a platform of your own definition by just "adding" it in the configuration manager, only the predefined platforms works, such as Win32, x64, etc. If you type a name of your own in the platform field when creating a new one, you cant select that platform for any of the projects when you want to setup new debug/release configurations for that platform. Must a new platform somehow be registered with visual studio? Thanks Peter
  12. Is there anything preventing you from using stl (msvc/other impls) when using threads? Used in safe contexts ofcourse (critical sections by the programmer). What im wonder is, is stl's container classes adn string etc using static's and such internally? Seems to be alot of crashes in stl in my program atm, but that could very well be me using same date from diffrent threads. But if done correctly when its ensured that no two threads are using the same stl contianer at the same time, will it work?
  13. When using ioctl() to set SIO_RCVALL in order to be able to use recvfrom() to "sniff" all incoming and outgoing packets, will TCP packets already be "ordered (arrive in same order as sent)" and and reliable in the sense that a copy of an already received packet can arrive at a later time? Or does SIO_RCVALL hook the packets before the tcp implementation have done its work, and you have to do this ordering and detecting dupes yourself? Thanks
  14. Thanks for your replies! Maybe im going about this the wrong way, what i want to do is to write an application that i can use to log my games network traffic. I am doing this by setting the SIO_RCVALL option with ioctl(), so that recvfrom() returns both sent and received packets. But using this option with ioctl() only works if i have bound my socket to a specific address, INADDR_ANY will cause it to fail. I suppose i could just enumerate all addresses and listen to them all, but that feels like a waste, and could complicate things if this application is run on a gateway machine and not infact the machine that is running the game. Since my game only supports multiplayer over internet via a matchmaking service, i need to know that im listening to the internet connected address. Does anyone have any better suggestion on how to solve this? hplus: ah, but can't a computer be connected to more than one gateway? Im not very good at networking theory, can a computer have internet access from more than one address? If so, how does it choose which one to use when sending packets to an internet address? Could you give me some hints to what these functions are on finding out what the default gateway is? Thanks.
  15. Hello. When im binding my socket, i want to find out what local address that is connected to the internet, if there are any, and bind() it to that address. What is the best way to get this info? getaddrinfo() dosn't know if an address is connected to a lan that has no internet access, or if it is connected to a lan with an internet forwarding gateway, or if its directly connected to internet via PPPoE or something like that. Maybe this info be found in the windows register? (just using INADDR_ANY dosn't cut it in this case, i need a specific address to bind to) To clearify what i want to use this for im writing an utility that moitors my internet traffic. Thanks in advance for any input.
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!