DLLs and Networking question

Just starting out? Need help? Post your questions and find answers here.
Shadow2002
User
User
Posts: 12
Joined: Mon Feb 20, 2006 7:17 am
Location: Lost in CyberSpace

DLLs and Networking question

Post by Shadow2002 »

Hey Guys and Gals. I'm running into a issue I was hoping I could get some help with. I've been working on a small dll using Pure Basic. I wanted to use Pure Basic to create a dll to help out a friend with networking his in house app. Basically its not much, just needs to push strings to and from servers. I'll cut to the point before you fall asleep. This is all I have done on the DLL so far...

Code: Select all

  
ProcedureDLL N_Init()

  If InitNetwork() = 0
    MessageRequester("Network Error","There was a error")
  EndIf
  
  
EndProcedure

ProcedureDLL N_Connect(serverAddress.s)
  
  port = 4010
  Global ConnectionID = OpenNetworkConnection(serverAddress.s,port)
  MessageRequester("Demo", "This is a beta dll and should not be in public domain.")
  MessageRequester("",Str(ConnectionID))
    
EndProcedure

ProcedureDLL N_SendString(stringToSend.s)
  
  MessageRequester("",Str(ConnectionID))
  ; SendNetworkString(,"stringToSend.s")
  
EndProcedure
All works good until the procedure N_SendString is called. His app will crash. I tried to test it out using pure basic to make the calles using the fallowing code.

Code: Select all

If OpenLibrary(0,"network.dll")
  
  CallFunction(0,"N_Init")
  CallFunction(0,"N_Connect","127.0.0.1")
  
  If CallFunction(0,"N_SendString","Hello World")
    MessageRequester("","Success!")
  Else
    MessageRequester("","Failed")
  EndIf  

EndIf
But sadly it too crashed. If you have any suggestions it would be helpful. Thank you all for your time.
JCV
Enthusiast
Enthusiast
Posts: 580
Joined: Fri Jun 30, 2006 4:30 pm
Location: Philippines

Post by JCV »

Are you trying to create a wrapper of PB Network Lib?
I think youre not allowed to do that. :roll:
Shadow2002
User
User
Posts: 12
Joined: Mon Feb 20, 2006 7:17 am
Location: Lost in CyberSpace

Post by Shadow2002 »

I'm not trying to build a wrapper for the library. I was just trying to build a simple solution for a bigger problem. It looks as I may just have to hit c++ because I cant seem to find a way to get it to work with pb.

Just looking for a fast solution thats all. Nothing more, nothing less. But thanks for the help anyway.
Shadow2002
User
User
Posts: 12
Joined: Mon Feb 20, 2006 7:17 am
Location: Lost in CyberSpace

Post by Shadow2002 »

Well he's decided to go with the C++ option. But that does bring up a good point. So if I where to build a dll to bring some older apps up to date using pb I wouldn't be able to include any of the libs? Thats rough. It would have been nice to create a set of dlls that I could use across the board. I like PB because of its quick development time and ease of use but I didnt know that was one of the restrictions. I guess my buddy is right. I just need to bite the bullet and do it all through c++.
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post by Rings »

shouldn't
SendNetworkString(,"stringToSend.s")
be
SendNetworkString(ConnectionID,"stringToSend.s")
and ConnectionID be global and <>0 ?
SPAMINATOR NR.1
Shadow2002
User
User
Posts: 12
Joined: Mon Feb 20, 2006 7:17 am
Location: Lost in CyberSpace

Post by Shadow2002 »

Rings wrote:shouldn't
SendNetworkString(,"stringToSend.s")
be
SendNetworkString(ConnectionID,"stringToSend.s")
lol, you are correct. I was messing around with it and I guess I forgot to put ConncectionID back in when I copy and paisted it. :lol: Sorry

But you are right!
Post Reply