473,396 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to store incoming packets or how to allocate pool of free space for the packets?

I am doing a project in embedded system (in vc++.net 2003)...I need to allocate a pool of free space for the incoming packets.Once i received the packet in the pool, an intimation must be given to me that the requested packet has come.How to do this?

Meanwhile, an packet comes for another process which runs in the backend,an intimation must be given for that process.I know, it is possible by multithreading. I need some ideas, how to implement this? How to generate the intimation? Awaiting for the response...
Jul 17 '08 #1
3 1240
Ok, so if I understand you right. You want a thread running, constantly receiving, and adding the received packets to a pool, then when a certain packet is received, you another thread or something to be notified of it?

if so, then you could allocate your 'pool of packets' as a queue.. Then just add stuff to it when received. Also, for the letting stuff know bit, then you could either have functions / threads that want packets 'subscribe' to this thread, with what kinda of packet it wants. Are the packets identifiable? Do they have a header which can indicate who 'wants' the packet? If so, why not just have your threads and functions that want packets Peek the top of the queue and check if the packet they want is on the top?

I dunno if this is what you want..

Ben Anderson,
Jul 17 '08 #2
Ok, so if I understand you right. You want a thread running, constantly receiving, and adding the received packets to a pool, then when a certain packet is received, you another thread or something to be notified of it?

if so, then you could allocate your 'pool of packets' as a queue.. Then just add stuff to it when received. Also, for the letting stuff know bit, then you could either have functions / threads that want packets 'subscribe' to this thread, with what kinda of packet it wants. Are the packets identifiable? Do they have a header which can indicate who 'wants' the packet? If so, why not just have your threads and functions that want packets Peek the top of the queue and check if the packet they want is on the top?

I dunno if this is what you want..

Ben Anderson,

Exactly sir...You are right. Packets are identifiable by the Feature ID. Can i implement this with Semaphore or InterProcess Communication or Just using threads? Which one is the best option..I don't know clearly about semaphores..Please explain it. I have to do it in VC++.Net 2003. Please give me the basic idea behind this...
Jul 17 '08 #3
Lol. I've no idea what a SemaPore thing is either, i'd check out the http://en.wikipedia.org/wiki/Semaphore_(programming).

But i'd just use threads.. that should work fine. Have a thread looking called a recieve call, even a blocking one (non async) should be fine as long as the loop never terminates.. Unless the program is shutting down, of course.

So if you create a queue of classes, each which have an array for all the bytes of the packet, and a enum for the type/header/FeatureID, then just have each thread/function that is requesting a packet 'peek' at the top item of the queue, if its the FeatureID it wants, the pop it off, and deal with it, else leave it and wait for its packet to be on the top. Provided all functions/threads looking for packets are polling the queue fairly constantly, this should work fine, and a big advantage is there is no need to manually declare all the memory.

Ben Anderson,
Jul 17 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: John Dalberg | last post by:
I am getting a "Could not allocate space for object 'temp_trc' in database 'Test' because the 'PRIMARY' filegroup is full" The database test has unrestricted growth (All the defaults). It resides...
5
by: lixiaoyao | last post by:
hi all I use matrix & vector function to allocate the space myself in c, typedef struct matrix_array newdata; struct matrix_array{ float **sy,*sxx; }; newdata ndata;//new data struct...
4
by: Brian Rice | last post by:
I have a socket application that is sending and receiving packets asynchronously. It works great except, when I receive packets that are larger than my receive buffer which then generate several...
3
by: Geof | last post by:
Hello, I need to write an application to monitor incoming UDP packets on a specific port. This UDP port is already in use by a third party application. The goal is : to execute some code...
1
by: | last post by:
I cannot handle this.I can receive incoming but I cannot detect outgoing packets. I am using Windows XP no SP present. Thanks a lot for answers.
3
by: ExclusiveResorts | last post by:
Can the CallContext be used reliably for storing request specific data? We are developing an application library that uses the CallContext to keep an IdentityMap (hashtable of business objects...
5
by: Björn Olsson | last post by:
Hello All. If I where to capture network traffic, dropping packets and modifying packets. I.e write firewall functionality. Which API or SDK would be the correct choice? I would prefer to do it...
20
by: ramasubramanian.rahul | last post by:
hi folks i have a peculiar problem. i have to allocate more than size_t consequtive bytes on a system . after i do a malloc .. i am unable to do a realloc because it takes size_t as a new size...
4
by: selvialagar | last post by:
I am doing a project in embedded system (in vc++.net 2003)...I need to allocate a pool of free space for the incoming packets.Once i received the packet in the pool, an intimation must be given to me...
7
by: Nash | last post by:
Hi, I have a Client and Server application which does communication using sockets(APM). The problem is Whenever the client is connected to a server i am storing the socket in a list. When...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.