General discussion

Locked

Updating linked list from a different pr

By David Ramos ·
Hello,

I am developing a chat program that has an NT service running on the server, and an unlimited number of remote clients connected. When the service is started, it calls the AddClients() function, which opens an Access Database and makes a linked list of all the usernames. On the website, running off the same server, I would like to have a CGI script that can add a new username to the user database, as well as to the linked list. If it just updates the database, which is relatively easy, the new user would not be able to log on until the service was restarted, at which time AddClients would once again load the current list, activating the new users. I cannot just restart the service every time there is a new username because all current clients are disconnected on restart.

Please help!

Thanks in advance,

-David Ramos-
dramossd@pacbell.net

This conversation is currently closed to new comments.

9 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Updating linked list from a different pr

by gpassare In reply to Updating linked list from ...

I do not know CGI, but here are three algorithims for adding to a dynamic linked list.

1. Adding to the head of a list.

function add_to_head(list:list_ptr)
\\ you will need to pass the list to this \\function.
{
new_node:list_ptr;
new(new_node);
new_node*.your_stuff=<set all fields here>
\\there should be a function to pull a new \\memory block from the system heap.
new_node*.next = list;
list = new_node;
}
note: you will need to look up the 'next' field for the records you are using. The '*' is a pionter to the memory pulled from the heap.

2. Adding to the end of a list.

function add_to_end(list:list_ptr)
{
current:list_ptr;
new_node:list_ptr;

new(new_node);
new_node*.next = null;
new_node*.your_stuff = <set all fields here>
current = list;
while (current*.next != null)
{
current = current*.next;
}
\\ walks to the end of list, use whatever loop you wish.
current*.next = new_node;
}

3. adding to an ordered list

function i

Collapse -

Updating linked list from a different pr

by David Ramos In reply to Updating linked list from ...

The question was auto-closed by TechRepublic

Collapse -

Updating linked list from a different pr

by gpassare In reply to Updating linked list from ...

3. adding to an ordered list

function insert_sort(list:list_ptr)
{
prior = list_ptr;
current = list_ptr;
new_node = list_ptr;

new(new_node);
current = list;
prior = null;
new_node*.your_stuff \\set your fields here
while (current*.index < new_node*.index)
{
current = current*.next;
prior = current
}
\\ finds the spot in the list for the new \\node.
if (prior = null) then
add_to_head(list)
else
{
new_node*.next = current;
prior *.next = new_node;
}
}
NOTE: If you can get away with it, I recamend using the first one.

Collapse -

Updating linked list from a different pr

by David Ramos In reply to Updating linked list from ...

The question was auto-closed by TechRepublic

Collapse -

Updating linked list from a different pr

by prasanna_mishra In reply to Updating linked list from ...

What you are doing now is adding all the users in your databse to the link list even if the user is not logged in. This increses your link list length without reason. You can add users to your link list only when required.

When a new user registers you can add him to the link list if chooses to by many algorithms. Such algorithms are available on any book on linked lists. The algorithm given by answer 1&2 is also good. Adding users to a current list does not require restart of service.
Hope this will help you.

Prasanna

Collapse -

Updating linked list from a different pr

by David Ramos In reply to Updating linked list from ...

The question was auto-closed by TechRepublic

Collapse -

Updating linked list from a different pr

by sfernandez In reply to Updating linked list from ...

My thought on this one is to use a memory mapped file in NT. Both processes can access a file created by the NT service (I would use a GUID for the file name uniqueness reasons).

Minimal coding effort required. If you want a large list, you canback it with virtual memory and the list gets paged as required.

There are other solutions, but they involve things like singleton objects and are more involved to get working.


Stephen

Collapse -

Updating linked list from a different pr

by David Ramos In reply to Updating linked list from ...

The question was auto-closed by TechRepublic

Collapse -

Updating linked list from a different pr

by David Ramos In reply to Updating linked list from ...

This question was auto closed due to inactivity

Back to Web Development Forum
9 total posts (Page 1 of 1)  

Software Forums