| 146 | // } |
| 147 | |
| 148 | void SchemeREPL::writeString(std::string& string) |
| 149 | { |
| 150 | if(server_socket == 0) return; |
| 151 | write_lock->lock(); |
| 152 | |
| 153 | char c1 = 13; |
| 154 | char c2 = 10; |
| 155 | string.push_back(c1); |
| 156 | string.push_back(c2); |
| 157 | |
| 158 | int length = string.length(); |
| 159 | const char* b = string.c_str(); |
| 160 | |
| 161 | for(;;) { |
| 162 | int lth = (length > 1024) ? 1024 : length; |
| 163 | #ifdef EXT_BOOST |
| 164 | int chars_written = server_socket->write_some(boost::asio::buffer(b, lth)); |
| 165 | #else |
| 166 | int chars_written = write(server_socket, b, lth); |
| 167 | #endif |
| 168 | if(chars_written != lth) { |
| 169 | printf("There was an error sending this expression to the interpreter. Check for non-ascii characters in your code.\n"); |
| 170 | } |
| 171 | length -= lth; |
| 172 | if(length < 1) { write_lock->unlock(); return; } |
| 173 | b+=lth; |
| 174 | } |
| 175 | write_lock->unlock(); |
| 176 | return; |
| 177 | } |
| 178 | |
| 179 | bool SchemeREPL::connectToProcessAtHostname(std::string& hostname, int port) |
| 180 | { |