
-----------------------------------
timeisup
Tue Mar 21, 2006 7:27 pm

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...

:canada:

-----------------------------------
Tony
Wed Mar 22, 2006 12:41 am


-----------------------------------
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?

-----------------------------------
timeisup
Wed Mar 22, 2006 6:17 pm


-----------------------------------
sorry for not being specific but here is the easiest example of this problem


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
Thu Mar 23, 2006 3:39 pm


-----------------------------------
that cannot be right :? 

have you tried the code outside of processes?


    var netstream : int
    loop
        netstream := Net.OpenConnection ("127.1", 5055)
        exit when netstream > 0
    end loop
put "connected"

and

    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.

-----------------------------------
timeisup
Thu Mar 23, 2006 5:33 pm


-----------------------------------
Wow that worked...... :oops:  :roll:  is there any reason why this error occurs when placed inside of a process? or even in a procedure?

-----------------------------------
Tony
Thu Mar 23, 2006 9:43 pm


-----------------------------------
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 :?
