Author |
Message |
timeisup

|
Posted: Tue Mar 21, 2006 7:27 pm Post subject: Net.CloseConnection crashes |
|
|
I do not know why but when ever i use Net.CloseConnection my program crashes with a General protection (segmentation) fault .
Can someone help me please
I am sorry if i'm double posting but i can't find help on this...
 |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Tony

|
Posted: Wed Mar 22, 2006 12:41 am Post subject: (No subject) |
|
|
general errors suck due to their lack of description..
maybe you're using a wrong id for the connection?
could you isolate the problem to a test case? |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
timeisup

|
Posted: Wed Mar 22, 2006 6:17 pm Post subject: (No subject) |
|
|
sorry for not being specific but here is the easiest example of this problem
code: |
process client
var netstream : int
loop
netstream := Net.OpenConnection ("127.1", 5055)
exit when netstream > 0
end loop
end client
process server
var adress : string
var server : int
loop
server := Net.WaitForConnection (5055, adress)
exit when server > 0
end loop
Net.CloseConnection (server) %crashes
end server
fork server
fork client
|
i fork the server and a client they connect but when i try to disconnect it; it gives me that error ; i've also tried to close the connection in the client ; neither of them have worked
i don't think that it is my syntax but if it is please correct me |
|
|
|
|
 |
Tony

|
Posted: Thu Mar 23, 2006 3:39 pm Post subject: (No subject) |
|
|
that cannot be right
have you tried the code outside of processes?
code: |
var netstream : int
loop
netstream := Net.OpenConnection ("127.1", 5055)
exit when netstream > 0
end loop
put "connected"
|
and
code: |
var adress : string
var server : int
loop
server := Net.WaitForConnection (5055, adress)
exit when server > 0
end loop
put "connection established"
Net.CloseConnection (server)
put "connection dropped"
|
if you compile both programs, you can run two executables at the same time. This way you don't have to worry about what's going on with processes. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
timeisup

|
Posted: Thu Mar 23, 2006 5:33 pm Post subject: (No subject) |
|
|
Wow that worked...... is there any reason why this error occurs when placed inside of a process? or even in a procedure? |
|
|
|
|
 |
Tony

|
Posted: Thu Mar 23, 2006 9:43 pm Post subject: (No subject) |
|
|
procedure should work..
as for processes, it has to do with how they work. I'm not sure why you were using them without understanding of what they do exactly. Read up on some tutorials that try to explain the consepts. Basically the two forks take turns executing, in a not very organized manner.. In theory you should not be able to even establish a connection like this, as at no point you're opening and listening at the same time  |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
|