CURL.SetOptionLocalPort
-----------------------

This sets the local port number of the socket used for connection.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [CURL](component_CURL.md) | [2.5](newinversion25.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "CURL.SetOptionLocalPort"; curl; Value ) 

**MBS**( **"CURL.SetOptionLocalPort";** /\* This sets the local port number of the socket used for connection. \*/  
**$curl**; /\* The CURL session handle. \*/   
**$Value**) /\* The port number (1-65535)e.g. 8000 \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| curl | The CURL session handle. | $curl |
| Value | The port number (1-65535) | 8000 |

### Result

Returns "OK" on success.

### Description

This sets the local port number of the socket used for connection.  
This can be used in combination with [CURL.SetOptionInterface](CURLSetOptionInterface.md) and you are recommended to use [CURL.SetOptionLocalPortRange](CURLSetOptionLocalPortRange.md) as well when this is set. Valid port numbers are 1 - 65535.  
  
Local ports &lt;1024 usually need admin/root permissions to be used.  
To set port to connect to, please use [CURL.SetOptionPort](CURLSetOptionPort.md) instead.  
See also [LOCALPORT](https://curl.haxx.se/libcurl/c/CURLOPT_LOCALPORT.html) option in CURL manual.

### See also

- [CURL.SetOptionFTPPort](CURLSetOptionFTPPort.md)
- [CURL.SetOptionInterface](CURLSetOptionInterface.md)
- [CURL.SetOptionLocalPortRange](CURLSetOptionLocalPortRange.md)
- [CURL.SetOptionPort](CURLSetOptionPort.md)
- [CURL.SetOptionProxyPort](CURLSetOptionProxyPort.md)

Created 18th August 2014 , last changed 8th February 2019

  
[CURL.SetOptionKeyPassword](CURLSetOptionKeyPassword.md) - [CURL.SetOptionLocalPortRange](CURLSetOptionLocalPortRange.md)

[HTML Version](CURLSetOptionLocalPort.shtml)