1. Berka Frenfert
  2. PowerBuilder
  3. Wednesday, 17 August 2022 12:16 PM UTC

Error# 10014

Error description: The system detected an invalid pointer address in attempting to use a pointer argument in a call.

Reason: This error occurs if an application passes an invalid pointer value, or if the length of the buffer is too small. For instance, if the length of an argument, which is a SOCKADDR structure, is smaller than the sizeof(SOCKADDR)

(posted by VictorN in 2003; https://forums.codeguru.com/showthread.php?468828-Socket-error-10014-when-sending)

Suggestion:

int BytesToSend = 120;
int sendBytes = send(Soc, (char*) &BytesToSend, sizeof((char*)BytesToSend), 0);

Question: I have 2 applications one behave as server and other is client. server and client share some data. Everything was working until i increased the size of data that goes from server to client. as you can see the debug output.

debug output image

How to apply the change described in Suggestion section?

External function:

Function integer send (int socket, ref blob buf, int len, int flags) Library "wsock32.dll" 

 

Call to the send() function goes as following

public function integer uf_senddata (unsignedinteger asocket, blob ab_data);boolean lb_error
lb_error = false
if not ib_initialized then
	if uf_initialize() = SOCK_ERROR then
		lb_error = true
	end if
end if

int retval
if not lb_error then
//	blob lb_data
//	lb_data = blob(as_data)
	retval = send(asocket, ab_data, Len(ab_data),0)
	if retval = SOCK_ERROR then
		RecentError = uf_geterror()
		lb_error = true
	else
		RecentError = 0
		return retval  /// its not the error
	end if
end if

If lb_error then
	return SOCK_ERROR
end if

end function

 

The call to the uf_senddata() is giving error because whole syntax of the dw was sent to it. But when i use just

dwDataSyntax = dw_1.Object.DataWindow.Syntax.Data

then there is no error (there is just one row but data will increase in future and i expect the same error)

Integer ret
	String 	dwsyntax
	dwsyntax = LibraryExport(GetCurrentDirectory() + "\dweQuery.srw", "dwe_query_status", ExportDataWindow!)	
	ret = u_test.uf_senddata(clientsock, Blob(dwsyntax))
	
	IF Ret < 0 THEN
		MessageBox(String(ret) + " :: " + String(RecentError), of_getErrorText(RecentError))
	ELSE
		MessageBox(of_getErrorText(RecentError), ret)
	END IF

 

 

 

Accepted Answer
René Ullrich Accepted Answer Pending Moderation
  1. Friday, 19 August 2022 14:24 PM UTC
  2. PowerBuilder
  3. # Permalink
The value the send function returns is the number of bytes. Is this smaller then specified len? Look in winsock example. It shows how to send the additional bytes.
Comment
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Wednesday, 17 August 2022 13:10 PM UTC
  2. PowerBuilder
  3. # 1

 

Maybe the blob is larger then the systems message buffer size. In this case you must send the data in parts and combine them at the destination.

Comment
  1. Berka Frenfert
  2. Thursday, 18 August 2022 07:36 AM UTC
That must be the reason. But joining data in parts will become too complex. i want to avoid that thing. Trying to use Roland's example. hope his code wont have these limits.
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Wednesday, 17 August 2022 12:59 PM UTC
  2. PowerBuilder
  3. # 2
Comment
  1. Roland Smith
  2. Friday, 19 August 2022 11:53 AM UTC
There aren't try/catch blocks in my code. It is triggering an error when there wasn't one. Just use it as I coded it.
  1. Helpful
  1. Berka Frenfert
  2. Friday, 19 August 2022 14:22 PM UTC
I am so sorry Roland, That was my mistake.

The RecentError is 0 and RecentErrorBuffer = "The operation completed successfuly." is actually because i was debugging the code. I had to run the code to get real error code and description.

The old program that i was working on before worked for me this time. There were 3 important things i missed or i would say i overlooked.

1st: the RecentError must be set by calling WSAGetLastError() and of_GetLastError

2nd: the send function must be the following way

Correct: Function long send ( Ulong socket, Ref blob buf, long len, long flags ) Library "ws2_32.dll"

Wrong: Function integer send (int socket, ref blob buf, int len, int flags) Library "wsock32.dll"

3rd: and the most stupid one , i did not change the blob size at client side where data was received. size of blob was supposed to be increased.

i just increased the size of blobl as following and received the whole dw syntax on client side

if not lb_error then

blob{10790} lb_request

if recv(asocket, lb_request, 10790, 0) = SOCK_ERROR then

RecentError = uf_geterror()

lb_error = true

else

RecentError = 0

return lb_request

end if

end if



I checked size when Rene told me to do so. Server was sending 10790 but client was just 2048.

I checked two projects in parallel but later one as you told me to use your example was not completed because of the getaddrinfo error https://ibb.co/WcrtMk4. That seemed more horrible that the limited output. I then moved back to fix the terminated data problem. i thought i was not sending full data but actually i was not receiving full data.



I am glad you guys helped me a lot and without it i am sure was going to waste much more time.

I really want to thank you and Rene.

True regards

Berka
  1. Helpful
  1. Berka Frenfert
  2. Friday, 19 August 2022 14:39 PM UTC
Yes, about the try/catch , that is strange thing why i see many crashes. i have to check that tomorrow. mostly send crashed.
  1. Helpful
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Wednesday, 17 August 2022 12:34 PM UTC
  2. PowerBuilder
  3. # 3

Looks like "len" parameter is not the correct length of "buf" parameter.

Please provide more information how you set this two parameters.

Comment
  1. Berka Frenfert
  2. Wednesday, 17 August 2022 13:23 PM UTC
I replaced the older send() and dont see the error 10014 now

But client received terminated output.sent text is not complete syntax of the datawindow.
  1. Helpful
  1. Roland Smith
  2. Friday, 19 August 2022 11:56 AM UTC
PB strings are Unicode and therefore 2 bytes per character. The length parameter is in bytes so you need to multiply the string length by 2. My code handles that by converting the string to a blob and then passing it to the blob version of of_send.
  1. Helpful
  1. Berka Frenfert
  2. Friday, 19 August 2022 14:36 PM UTC
I will check that also because my dw syntax not gonna be fixed and i have to keep the size of blob(client side) dynamic somehow.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.