Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Net.CloseConnection crashes
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
timeisup




PostPosted: 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...

Canada
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: 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?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
timeisup




PostPosted: 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




PostPosted: Thu Mar 23, 2006 3:39 pm   Post subject: (No subject)

that cannot be right Confused

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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
timeisup




PostPosted: Thu Mar 23, 2006 5:33 pm   Post subject: (No subject)

Wow that worked...... Embarassed Rolling Eyes is there any reason why this error occurs when placed inside of a process? or even in a procedure?
Tony




PostPosted: Thu Mar 23, 2006 9:43 pm   Post subject: (No subject)

procedure should work.. Confused

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 Confused
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: