winsock programming

I hope someone will be able to help me. I am using PB10.5 build 4523 and I 
am trying to obtain the ip address and port of connected client socket
uisng the winsock 2 API WS2_32.dll

I have declared an extranl function as follows

Function Integer getpeername( uint socket, Ref sockaddr addr,Ref integer 
addrlen ) Library "ws2_32.dll"

and I then make a call to this external function from within a function I 
created named of_getpeername which accepts aui_socket as an argument, where 
aui_socket is the handle to the connected socket.
as show below:

Integer  li_rtn, li_length
sockaddr lstr_sockaddr
String  ls_errmsg

li_length = 16
li_rtn = getpeername(aui_socket, lstr_sockaddr, li_length)
If li_rtn <> 0 Then
  ... process error
Else
 MessageBox("I",String(ntohs(lstr_sockaddr.sin_port)))
End If

 Return(li_rtn)

The messagebox  gives me the correct client port value but as soon as the 
return statement is executed the system crashes and a visual studio just in 
time debugger window opens
informing me that An unhandled win32 exception has occurred in the 
PB105.exe.


0
Robert
4/6/2006 1:26:44 AM
sybase.powerbuilder.general 62418 articles. 19 followers. Follow

2 Replies
493 Views

Similar Articles

[PageSpeed] 23

Robert Passam wrote:
> I hope someone will be able to help me. I am using PB10.5 build 4523 and I 
> am trying to obtain the ip address and port of connected client socket
> uisng the winsock 2 API WS2_32.dll
> 
> I have declared an extranl function as follows
> 
> Function Integer getpeername( uint socket, Ref sockaddr addr,Ref integer 
> addrlen ) Library "ws2_32.dll"
> 
> and I then make a call to this external function from within a function I 
> created named of_getpeername which accepts aui_socket as an argument, where 
> aui_socket is the handle to the connected socket.
> as show below:
> 
> Integer  li_rtn, li_length
> sockaddr lstr_sockaddr
> String  ls_errmsg
> 
> li_length = 16
> li_rtn = getpeername(aui_socket, lstr_sockaddr, li_length)
> If li_rtn <> 0 Then
>   ... process error
> Else
>  MessageBox("I",String(ntohs(lstr_sockaddr.sin_port)))
> End If
> 
>  Return(li_rtn)
> 
> The messagebox  gives me the correct client port value but as soon as the 
> return statement is executed the system crashes and a visual studio just in 
> time debugger window opens
> informing me that An unhandled win32 exception has occurred in the 
> PB105.exe.

There is a free winsock example at http://www.topwizprogramming that you 
should probably look at. You may be able to use it instead of writing 
your own... but at the very least it would give you some tips and 
pointers on how to do what you need.
0
Jason
4/6/2006 5:43:35 PM
> The messagebox  gives me the correct client port value but as soon as the 
> return statement is executed the system crashes and a visual studio just 
> in time debugger window opens
> informing me that An unhandled win32 exception has occurred in the 
> PB105.exe.

I would guess that you are assuming that the winsock functions will use the 
shorter versions of the addr structure when, in fact, the newer version is 
used.  That raises the question of how to know which structure is 
used/assumed by the winsock functions - you'll likely need to look at the 
documentation for that. 


0
Scott
4/6/2006 6:32:36 PM
Reply:

Similar Artilces:

WinSock Programming in Powerbuilder
Hi, I have a application server developed in PowerBuilder 5.0 on Windows NT, we have around 400 clients. Clients sends/recieve message to server using Mailslot (UDP) protcol for further processing to other system. It is a two way message communication between client and server. Since message through mail slot communication layer is not supported in higher version (windows 2000). We want to change communication layer to winsock - TCP. We are trying to do this, using third party OCX control using OLE. Can any one help to find reliable third party tool which can be impemented in PB 5....

powerbuilder program in citrix environment
We have a program written in powerbuilder deployed using citrix. Users connect to our program through citrix log on. The program runs in citrix server and user sees the seamless screen. From this program we need to execute a client program such as excel, acrobat reader or Internet explorer . 1) Used run command in powerbuilder but excel or iexplore runs in server side and screen transmit to user. 2) Tried using ole and show the files but same thing. can anyone help with this? Thank you in advance If not "seamless" does it work? (ie - log into a Citrix deskto...

What generals generally do
Reading a McChrystal thread elsewhere, I came across someone quoting a US general http://en.wikipedia.org/wiki/Smedley_Butler > I spent 33 years and four months in active military service and > during that period I spent most of my time as a high class thug for > Big Business, for Wall Street and the bankers. In short, I was a > racketeer, a gangster for capitalism. I helped make Mexico and > especially Tampico safe for American oil interests in 1914. I helped > make Haiti and Cuba a decent place for the National City Bank boys to > collect revenues in. I ...

Announcing the PowerBuilder 10 Public Beta Program!Join the PowerBuilder 10.0 Beta Team!
Join the PowerBuilder 10.0 Beta Team! PowerBuilder is getting ready for the 10.0 release and would like to invite you to join the Beta Team! The exciting new developments you will have early access to as a member of the Beta Team include: Unicode support DataWindow.NET Object Oriented Modeling with PowerDesigner plug-in UDDI search ADO.NET support NETXML Web Datawindow Your participation in the beta test cycle is an opportunity to provide valuable feedback to engineering regarding the quality and capabilities of this release. As a member of the team, you will learn from the e...

winsock program with pb
hi everyone: what's the best way to develop winsock pb program? winsock.pbl or MSWINSCK.OCX or ? ...

Powerbuilder Service Program
Is it possible to write a powerbuilder program as a service program? For example, the master program will work as a 'add' service program. I write another program and send parameter 1 & 2 to the master program and it will return 3 (1 + 2). I know that it is possible to write a web service but I don't want to implement IIS on the client site. Thanks John Smith http://www.topwizprogramming.com/pbniserv.html Report Bugs to Sybase: http://case-express.sybase.com/cx/welcome.do Product Enhancement Requests: http://my.isug.com/cgi-bin/1/c/submit_enhancement ...

General programming question
Hello, I need to include the nsISound.h file into mailnews/base/search/src/nsMsgFilterService.cpp. How do I do that? The compiler reports that it cannot find the include file. The mozilla.org hacking page tells me that all include files get copied to dist/include during the build process. Regards, Mark Mark Stier wrote: > Hello, > > I need to include the nsISound.h file into > mailnews/base/search/src/nsMsgFilterService.cpp. > > How do I do that? The compiler reports that it cannot find the include > file. The mozilla.org hacking page tells me ...

filenet programming in Powerbuilder
Hi Friends I want to be corrected if I am wrong about my theory. I am guessing that filenet programming in PB environment is possible using OLE scripting. I create Filenet objects in using OLE object, create statement and then access all the properties and methods of the Filenet objects. In fact in our present application for printing the various forms, we are using OLE scripting, to create the word application and then using the word application methods and properties. Can I do same thing with Filenet also. Anyideas or suggestions are highly appreciated. TIA RAO ...

using winsock in powerbuilder
Dear sir I'm a PowerBuilder programmer. I found a error when doing an application now. I use PowerBuilder 6.5 under Sybase Enterprise Server System 11. I want to make comminucation from one station to another station by dial line. I use Winsocket on windowsNT & windows95/98. I use PowerBuilder to do the Winsocket Server program. If I connect to the Winsocket Server only one client, all is right. But if I connect to this server more than 2 links, some time later, only one connection is active, other links is disactive because the Winsoc...

winsock pb program
hi everyone: what's the best way to develop winsock pb program? winsock.pbl or MSWINSCK.OCX or ? http://www.topwizprogramming.com/freecode_winsock.html "lwl" <lwl@esunsoft.cn> wrote in message news:4a954fad@forums-1-dub... > hi everyone: > > what's the best way to develop winsock pb program? winsock.pbl or > MSWINSCK.OCX or ? > > > ...

GetHost(about winsock programming)
hi~ I'am maintaining the program for a company The program is using socket (FTP) Today, I face to face with error which fails on gethost call. What means? how to mend ? --->Declare Local External Functions FUNCTION string GetHost(string lpszhost, ref string lpszaddress ) library "pbws.dll" ---> part of call is_hostname = ws.GetHost(ps_host, is_hostaddress) ----> my version of PB 5.0.0.2 I need your help~!!!!!!!! ...

Programming ArcObjects from Powerbuilder
Has anyone worked with ESRI's ArcObjects ESRICore library 8.1? We're trying to access the tools from Powerbuilder, but are not having any success. We are currently on PB version 7.0.3 build 10009. We would like any suggestions. T. Floor I've looked at the problem a little. The primary problem seems to be that there are multiple interfaces defined for each COM object (unlike the simple single-interface-per-object scheme used by MapObjects.) I'm not sure, but from my experience using PB's COM interface, I don't believe PB has the intelligence to work with...

Socket programming in powerbuilder
Hi is there a way to open a socket in powerbuilder and send and recieve messages via sockets . thanx http://powerbuilder.codexchange.sybase.com/files/documents/67/1139/winsock32.pbl > > is there a way to open a socket in powerbuilder and send > and recieve messages via sockets . > > thanx > > And this: http://powerbuilder.codexchange.sybase.com/files/documents/67/755/socketwrenchpbl.zip ...

PowerBuilder Translator program
Hello group, I want to ask if there is any translation program for PowerBuilder in order to translate my applications from greek or english to other languages. I know that PowerBuilder comes with a translation toolkit. I am looking if there are any third party tools. I heard that Microsoft has one. Regards Dimitris Karistinos http://www.wizart.com/en/index.shtml On 19 Jul 2004 01:15:27 -0700, "Dimitris Karistinos" <dkaris@relational.gr> wrote: >Hello group, >I want to ask if there is any translation program for PowerBuilder in order >to transla...

Web resources about - winsock programming - sybase.powerbuilder.general

Computer programming - Wikipedia, the free encyclopedia
Computer programming (often shortened to programming or coding ) is the process of designing , writing, testing , debugging , and maintaining ...

Contract Junior Programmer (JAVA Programming) 151222/JP/851
Defining Technology for Australia's IT Leaders.

Extreme Programming Is People!
... in the ballroom of the Marriott hotel where XP/Agile Universe 2002 took place. It was the second North American conference on Extreme Programming ...

Craig Federighi promotes Hour of Code workshops, saying programming is “the next level of literacy”
... of Code workshops for kids aged 6 and up, SVP of software engineering Craig Federighi has told the BBC that introducing young children to programming ...

ABC’s Lincoln Square Productions to Double Programming Output
Lincoln Square Productions, the in-house production company at ABC News, plans to double the hours of original productions and syndicated programming ...

Netflix to double its lineup of original programming in 2016
If the sixteen original scripted shows launched on Netflix's streaming platform this year weren't enough to satisfy your thirst for new content, ...

HBO's programming exec just took the blame for the failure of 'True Detective' season 2
... season two was a disappointment to many fans. Some have blamed creator Nic Pizzolatto for the lackluster season, but HBO president of programming ...

Google hopes to remake programming with Go
A Unix co-creator is among those behind a language Google hopes will speed computers and programming. Today, Go becomes open-source software. ...

U.S. expects drop in programming jobs, but gains in IT jobs overall
The U.S. Bureau of Labor Statistics (BLS) says IT jobs will grow 12% over the next decade, except for programmers. That occupation will shrink ...

Discovery Vet Amy Savitsky Joins A&E Network As SVP Development & Programming
Discovery Communications’ veteran Amy Savitsky is moving to A&E Network as SVP Development & Programming. Based in New York, Savitsky will drive ...

Resources last updated: 1/8/2016 9:35:56 PM